Question : 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


Answer : Flash CS3 Timer routine

This should do the trick.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
public var crtItem = 0;
public var myArray = ["one", "two", "three"];
public function showPlay(){
        
            var wholeTimer:Timer = new Timer(1000); 
            wholeTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onWholeComplete); 
            wholeTimer.start();
            CircleFocus(myArray[crtItem]);
 
}
 
                        function onWholeComplete(event:TimerEvent):void{
                            CircleRemove(myArray[crtItem]);
                            crtItem++;
                            wholeTimer.stop();
                            if (crtItem < myArray.length)                                                                         
                                   showPlay();
                         }
Open in New Window Select All
Random Solutions  
 
programming4us programming4us