To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here


A Flash Developer Resource Site

Go Back   Flash Kit Community Forums > Flash Help > Flash ActionScript

Reply
 
Thread Tools Search this Thread Display Modes
Old 10-13-2004, 03:54 PM   #1
TheSheriff
...and the law won
 
TheSheriff's Avatar
 
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?
TheSheriff is offline   Reply With Quote
Old 10-13-2004, 04:29 PM   #2
jbum
Senior Member
 
jbum's Avatar
 
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:

code:

// Clear previous setInterval, if any:
clearInterval(_root.animate);
_root.animate = setInterval(_root.playMovieClip, 10000, this);
stop();

__________________
jbum is offline   Reply With Quote
Old 10-13-2004, 04:33 PM   #3
TheSheriff
...and the law won
 
TheSheriff's Avatar
 
Join Date: Feb 2004
Location: Philly
Posts: 235
thanks jbum, works swell.
TheSheriff is offline   Reply With Quote
Old 05-24-2006, 06:10 AM   #4
markive1
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.
markive1 is offline   Reply With Quote
Old 05-24-2006, 06:25 AM   #5
markive1
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();
}
markive1 is offline   Reply With Quote
Old 06-24-2008, 05:09 PM   #6
Axauv
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...
Axauv is offline   Reply With Quote
Old 06-24-2008, 05:40 PM   #7
gparis
Super Moderator
 
Join Date: Aug 2000
Location: Montréal
Posts: 13,431
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 AS tags for code samples || Flash LiveDocs || AS 2.0 Language reference (CS4)
gparis is offline   Reply With Quote
Old 06-25-2008, 02:08 AM   #8
Axauv
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!
Axauv is offline   Reply With Quote
Reply

Go Back   Flash Kit Community Forums > Flash Help > Flash ActionScript

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:47 PM.


internet.commerce
Be a Commerce Partner
 »  »  »  »  »  »  »
 »  »  »  »  »  »
 

    

Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.