Actionscript: pause
- Started
- Last post
- 36 Responses
- kreydle
i want to pause the main movie timeline for 5- 10 seconds, then resume. whats the best way to do that?
- kafeen330
_root.timer = 0;
function waiting() {
_root.timer++
if (_root.timer == 450) {
_root.gotoAndPlay("blah");
_root.timer = 0;
}
}this one is based on frame rate. so if your movie is 30fps, then this is sitting there for 15secs
i am sure there is one based on an object()... but i made this one up quickly for a project.
- kreydle0
awesome, yeah i was planning this for 30fps. Thanks. I will try this.
- ********0
on(keyPress ""){
if(pauseFlag == null){
pauseFlag = 1;
};
pauseMe();}
on(press){
if(pauseFlag == null){
pauseFlag = 1;
};
pauseMe();
}
- ********0
calling this shit:
var pauseFlag;
//pauseFlag = 0;
play();
function pauseMe() {
trace(pauseFlag);
if (pauseFlag == 1) {
gotoAndStop(_currentframe);
pauseFlag = 0;
} else {
if (pauseFlag == 0) {
gotoAndPlay(_currentframe);
pauseFlag = 1;
}
}
}
- ********0
then tweak the f*ck out of those variables.
- Anarchitect0
MovieClip.prototype.pause = function(status, delay) {
clearInterval(this.pauseLoop);
if (status) {
this.stop();
this.pauseLoop = setInterval(this, "pause", delay, false);
} else {
clearInterval(this.pauseLoop);
this.play();
}
};
trigger.onPress = function() {
myMC.pause(true, 2000);
};
- ********0
even better
- F_180
i might be able to do you one better.
MovieClip.prototype.timePause = function(s)
//var timePause = function (s)
{
var mc = this;
var ms = 1000 * s;
var timer = mc._name + "_stimer";
mc.stop();
mc.createEmptyMovieClip(timer,10...
mc[timer].time_in = getTimer();
mc[timer].onEnterFrame = function(){
if((getTimer() - this.time_in) >= ms){
mc.gotoAndPlay(mc._currentframe + 1);
this.removeMovieClip();
}
};
}---> drop that into the first frame of your movie.
then, on the frame you wish to pause, just add:
this.timePause (#);
# = number of seconds you want the timeline to stay paused for.
works like a charm.
- ********0
nice
- ganon0
setInterval is more versatile than an onEnterFrame....
Anarchitect wins...!
all good code btw...!
- ********0
I put my two cents in for a button, not sure what you were trying to do?
- F_180
uhh...ok. didn't know it was a comptetion.
*sigh* i'll never be a flash guru...
- kreydle0
excellent!
- ********0
ask and ye shall receive at NT
- level20
On a blank movie clip on the timeline (put a stop(); on the frame this clip is on).
Measured in 1000th of a second (2000 = 2 seconds), so this is ultra precise.
Script:
------
onClipEvent (load) {
start = getTimer();
}
onClipEvent (enterFrame) {
now = getTimer()-start;
if (now>5000) {
start = getTimer();
//Put what you want to happen here.
}
}
- ********0
no I gave that car to Dutchboy last week, sorry maybe next time.
- F_180
dude, i got yelled at for using onEnterFrame.
- ganon0
this.competition = "i might be able to do you one better.";
- ********0
haha
