[flash=200,200]http://dl.iteye.com/topics/download/27a92543-9a9a-3f01-bd04-4f10b4258ab8[/flash]
通过这个例子是不是可以说:[color=red]函数的调用顺序不一定决定函数的执行顺序.[/color]
[url]http://eric-616.iteye.com/blog/694555[/url]
通过这个例子是不是可以说:[color=red]函数的调用顺序不一定决定函数的执行顺序.[/color]
<?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"
minWidth="955" minHeight="600">
<s:layout>
<s:BasicLayout/>
</s:layout>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
/* */
import flash.utils.*;
private var id1:uint;
private var id2:uint;
private var id3:uint;
private function reset_textarea():void
{
textarea.text = "";
}
private function start_textarea():void
{
id1 = flash.utils.setInterval(fun1,1000);
id2 = flash.utils.setInterval(fun2,950);
id3 = flash.utils.setInterval(fun3,850);
}
private function stop_textarea():void
{
clearInterval(id1);
clearInterval(id2);
clearInterval(id3);
}
/* demo function defined */
private function fun1():void
{
if(textarea.text!=null)
{
textarea.text = textarea.text+"fun1()";
}
}
private function fun2():void
{
if(textarea.text!=null)
textarea.text = textarea.text + "fun2()";
}
private function fun3():void
{
if(textarea.text!=null)
textarea.text = textarea.text + "fun3()\r\n";
}
]]>
</fx:Script>
<s:Panel x="227.6" y="164.45" width="500" height="291" title="ActionScript函数调用顺序演示">
<s:TextArea id="textarea" x="101" y="10" editable="false" width="304" height="149">
</s:TextArea>
<s:Button label="Start" x="96" y="226" click="start_textarea()"/>
<s:Button label="clear" x="335" y="227" click="reset_textarea()"/>
<s:Button label="Stop" x="219" y="228" click="stop_textarea()"/>
</s:Panel>
</s:Application>
[url]http://eric-616.iteye.com/blog/694555[/url]