|
|
|
#1 |
|
...and the law won
Join Date: Feb 2004
Location: Philly
Posts: 235
|
Pause command
I have the following code placed in an empty frame on my main timeline
//Pauses the movie function playMovieClip(mc){ clearInterval(animate); mc.play(); } Then on other frame on the maintime line I have this code // _root.animate = setInterval(_root.playMovieClip, 10000, this); stop(); This pause function works fine. An animation plays in frame 1, stops, then once the pause command hits it mark, the movie goes to the next frame and duplicates the process. My problem is I have buttons that I use to go to specific frames on my main timeline. When I use the buttons to go to say frame 4 the timing is all off. Instead the time that I have defined in the above script, it jumps ahead to the next frame much faster. Anyone see something in the code that can be throwing me off? |
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Feb 2004
Location: Los Angeles
Posts: 2,920
|
Yeah, when you hit a button to directly jump to a frame, you still have an active setInterval from the previous pause. If you do a bunch of jumps, you are going to have a bunch of them fire off.
Whenever you jump to a frame, you should clear the last pause, if any, by doing this:
|
|
|
|
|
|
#3 |
|
...and the law won
Join Date: Feb 2004
Location: Philly
Posts: 235
|
thanks jbum, works swell.
|
|
|
|
|
|
#4 |
|
Junior Member
Join Date: May 2006
Posts: 2
|
I have been using code similar to this...
Here it is : stop(); var nDelayID:Number = setInterval(this, "pause", 800); // eg where 4000 is 4000 milliseconds function pause():Void { clearInterval(nDelayID); play(); // or nextFrame(); } My problem is, when someone clicks on a button that jumps through the timeline, the pause function halves in actual pause time. For example where I paused for 6 seconds now pauses for around 3? The code looks almost identical.. Unfortunately, I cannot send the .FLA The problem I have is I am using the pauses throughout a fairly large timeline.. My code should clear out any previous pauses.. but the problem is they get faster not doubling up..?!!?!? Any help/advice much appreciated.. Thanks in advance. |
|
|
|
|
|
#5 |
|
Junior Member
Join Date: May 2006
Posts: 2
|
Well, its the law of the Sod, but I think i've fixed it myself (4 once) about 5 mins after making this post..
Simple really, just add another clear interval before the code is initialised.. seems to fix it.. clearInterval(nDelayID); stop(); var nDelayID:Number = setInterval(this, "pause", 6000); // where 4000 is 4000 milliseconds function pause():Void { clearInterval(nDelayID); play(); // or nextFrame(); } |
|
|
|
|
|
#6 |
|
ninja army recruiter
Join Date: May 2008
Location: Austin, TX
Posts: 6
|
pausing
but how do you pause a movieclip in general. not for a few seconds, but until the user unpauses it. i see that the pause() function was removed when AS2.0 came out for some retarded reason.
all i want to do is pause a MC on button press, and unpause (resume from current frame) when the button is pressed again. should be the simplest things in the world. im writing AI in sidescrollers with complicated bosses/powerups/levels/animations but i can't pause lol... |
|
|
|
|
|
#7 |
|
Super Moderator
Join Date: Aug 2000
Location: Montréal
Posts: 13,239
|
fyi, there was never a pause() function, this is a custom function. To pause a MC simply say: stop(); and when the user wants to resume, use play();
gparis
__________________
![]() AS 2.0 Forum Guidelines || Use PHP tags for code samples || Flash9 LiveDocs || AS 2.0 Language reference (CS4) |
|
|
|
|
|
#8 |
|
ninja army recruiter
Join Date: May 2008
Location: Austin, TX
Posts: 6
|
hmm
well according to Adobe's website there was a pause function with "availability" in AS 1.0 only... whatever that means, i suppose that is custom function?
i did figure it out, scripting it for ALL movie clips in a scene is incredibly tedious, but i guess until they build a better mousetrap we're stuck with it. at least i got it workin! |
|
|
|
![]() |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|