Link to home
Start Free TrialLog in
Avatar of lexshine
lexshine

asked on

Flash CS3 Timer routine

I am working in Actionscript 3.0

I have two functions

startSomthing();

endSomething();

I also have an array

"one","two","three"


I need a routine that will move through the array and execute the following functions

startSomthing(); for a set amount of time, say 1 minute

endSomething(); execute the end routine after 1 minute

then repeat until all elements of the array have been passed through, so based on the array above it would last for 3 times.

I have tried some things in Actionscript but havent been able to figure out the routine to make this happen.

thanks


Avatar of Spy6
Spy6

Hi!

As I understand you want to call startSomething and then have another function that after 1 minute will stop the execution of startSomething. This is just not possible because Flash is single-threaded so as long as startSomething is running you cannot call another function. Also you can't just stop a function from executing.

Avatar of lexshine

ASKER

Well, Here is what I have going on now. I call showPlay() which calls the function CircleFocus which starts the action.

I then have a timer that shuts down the CircleFocus routine called CircleRemove.

That is the equivilent of startSomthing and endSmthing running.

What I need to know is how to move through the array and call showPlay(), then recognize when its done and go to the second element in the array and call showPlay() again, etc.


public function showPlay(){
	
            var wholeTimer:Timer = new Timer(1000, 15); 
            wholeTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onWholeComplete); 
            wholeTimer.start(); 
			
			
			function onWholeComplete(event:TimerEvent):void{
			CircleRemove();
 
 
			}
 
       CircleFocus();
 
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Spy6
Spy6

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial