Copy link to clipboard
Copied
If I want a function with a delay, such as a timer or a Loader, to complete before continuing after delay.
For example:
var i:int = new int();
var tim:Timer = new Timer(1000);
tim.addEventListener(TimerEvent.TIMER, goTim);
thisfun();
trace(i);
function thisfun():int{
tim.start();
return (i);
} // function thisfun
function goTim(event:TimerEvent):void{
i = i+1;
}
// returns 0 instead of 1
I was looking for something simpler such as 'break' or 'continue'.
The code I'm working with is a bit extensive, it will take some work to write a workaround.
Copy link to clipboard
Copied
0 is expected, not 1.
what are you trying to do or what are you confused about?
Copy link to clipboard
Copied
I want a delay before continuing to 'return', but I take it that's not possible with AS3 since it is single threaded.
I think I'll have to write some sort of workaround such as using setInterval and checking for conditions.
Copy link to clipboard
Copied
you appear to know how to use a timer to delay code execution so it's not clear why you're asking how to delay code execution.
Copy link to clipboard
Copied
I was looking for something simpler such as 'break' or 'continue'.
The code I'm working with is a bit extensive, it will take some work to write a workaround.
Copy link to clipboard
Copied
Maybe Workers are what you are looking for.
Worker - Adobe ActionScript® 3 (AS3 ) API Reference
Regards,
JC
Find more inspiration, events, and resources on the new Adobe Community
Explore Now