flex怎样调用actionscript
1个回答
推荐于2016-03-17 · 知道合伙人数码行家
关注
展开全部
实例代码如下:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="init()"
xmlns:supportClasses="com.esri.ags.skins.supportClasses.*" minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
public var timer:Timer;
private function init():void{
//表示0.0001秒执行一次
timer=new Timer(1);
timer.addEventListener(TimerEvent.TIMER,onTimer);
}
protected function button1_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
//单击按钮时无线执行
//执行计时器
timer.start();
}
private function onTimer(event:TimerEvent):void{
OnFc();
}
//需要执行的方法
private function OnFc():void{
}
//外部调用关闭方法
public function closeFc():void{
timer.stop();
}
]]>
</fx:Script>
<s:layout>
<supportClasses:AttachmentLayout/>
</s:layout>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<s:Button click="button1_clickHandler(event)"/>
</s:Application>
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="init()"
xmlns:supportClasses="com.esri.ags.skins.supportClasses.*" minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
public var timer:Timer;
private function init():void{
//表示0.0001秒执行一次
timer=new Timer(1);
timer.addEventListener(TimerEvent.TIMER,onTimer);
}
protected function button1_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
//单击按钮时无线执行
//执行计时器
timer.start();
}
private function onTimer(event:TimerEvent):void{
OnFc();
}
//需要执行的方法
private function OnFc():void{
}
//外部调用关闭方法
public function closeFc():void{
timer.stop();
}
]]>
</fx:Script>
<s:layout>
<supportClasses:AttachmentLayout/>
</s:layout>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<s:Button click="button1_clickHandler(event)"/>
</s:Application>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询