-
Need help writing function, with a timer
I'm pretty new to actionscript. I'm making a flash piece that has a particle system (flint particles) that's working pretty well... I want to write a function that uses a rollover and rollout even handlers to pause and resume the particle system.
To test the pause and resume action I have two buttons on the stage just to get my feet wet, and that's working great with this code...
Code:
pauseBtn.addEventListener( MouseEvent.MOUSE_DOWN, pauseParticles );
resumeBtn.addEventListener( MouseEvent.MOUSE_DOWN, resumeParticles );
function pauseParticles(e:MouseEvent){
//trace("pause button clicked");
emitter1.pause();
}
function resumeParticles(e:MouseEvent){
//trace("resume button clicked");
emitter1.resume();
}
Now what I want to happen is when the user rolls off of a mc (let's call it mouseDetect_mc), a timer begins and will call the "pauseParticles" function after 15 seconds... Then if the user rolls BACK over mouseDetect_mc the resumeParticles function will get called.
The tricky part (for me) is making sure that pause function isn't called if the user were to roll off for less than 15 seconds, and then roll back on (the particles should just continue as is).
-
Senior Member
You can just stop the timer (myTimer.stops() and use setTimeOut, which you set to 15 seconds and the timer will start again.
var intervalId:uint = setTimeout(myDelayedFunction, 15000);
function myDelayedFunction():void {
myTimer.start();
}
- The right of the People to create Flash movies shall not be infringed. -
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|