-
...and the law won
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?
-
Senior Member
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:
code:
// Clear previous setInterval, if any:
clearInterval(_root.animate);
_root.animate = setInterval(_root.playMovieClip, 10000, this);
stop();
-
...and the law won
thanks jbum, works swell.
-
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.
-
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();
}
-
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...
-
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
-
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!
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
|