Need help writing function, with a timer
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Need help writing function, with a timer

  1. #1
    Junior Member
    Join Date
    Nov 2008
    Posts
    24

    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).

  2. #2
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,435
    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. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width


HTML5 Development Center

Poll by Flashkit.com