-
Senior Member
Kill Pause function prior to actions exicuting
I have a pause function that fires when the first frame of my swf loads.
PHP Code:
/************************************** Welcome transition ***************************************/ function pauseMC(sec) { var i = sec - 1; var MyPause = setInterval(function () { if (i == 0) { clearInterval(MyPause); _root.welcome.gotoAndPlay(3); // action to continue _root.welcome.vidPlayer_1.playVideo(); } i--; }, 1000); }
pauseMC(3);
However, if the user navigates away from this "Welcome" section, the actions following the "pause" still fire. I need to find a way to stop the pause function prior to the actions executing.
Below is the function used to trigger the navigation events and where I should be executing the action to stop by pauseMC.
PHP Code:
function moveLeft () { var t = this; this.opened = true; //this._x = _root.navWidth * this.index; var handler = new Tween(this, "_x", easingType, this._x, _root.navWidth * this.index, duration, true); this.gotoAndStop(2); // // try to stop pauseMC prior to pause ending - NOT WORKING // clearInterval(MyPause);
// // stop video player if transition has completed and user decides to // navigate away - WORKING // _root.welcome.vidPlayer_1.pauseVideo(); handler.onMotionFinished = function () { } }
Just one additional note, all my functions live on frame one of my main timeline.
Any assistance would be much appreciated. Thanks.
Last edited by hothousegraphix; 10-21-2009 at 11:53 AM.
-
FK'n_dog
try removing the var declaration to open the scope of MyPause -
MyPause = setInterval(function ()
compiles as -
Variable _level0.pauseMC = [function 'pauseMC']
Variable _level0.MyPause = 1
var MyPause = setInterval(function ()
compiles as -
Variable _level0.pauseMC = [function 'pauseMC']
MyPause is scoped only within the above function
-
Senior Member
ok, so I get that I've narrowed the scope of the interval to just the pause function so I should be able to do something like?
PHP Code:
function pauseMC(sec) { var i = sec - 1; if (i == 0) { clearInterval(MyPause); _root.welcome.gotoAndPlay(3); // action to continue _root.welcome.vidPlayer_1.playVideo() } i--; } var MyPause = setInterval(pauseMC,3);
But this isn't working - to be honest with you, no surprise because now I'm confused about how the counting function should be set up. I'm assuming that by declaring the MyPause variable equal to the setInterval which references the pause function and passes the value that I no longer need to call the function independently?
What am I doing wrong in the pause function itself?
-
FK'n_dog
setInterval requires at least two parameters -
setInterval(Function, interval Number in msecs)
so try this method -
PHP Code:
var i:Number = 3;
function pauseMC(){
trace(i);
i--;
if (i == 0) {
clearInterval(MyPause);
trace("cleared");
}
};
var MyPause = setInterval(pauseMC,1000); // 1000=1 sec
-
FK'n_dog
here is another method -
PHP Code:
_global.pauser = function(clip, sec) {
trace("pausing "+clip+" for - "+sec+" secs")
clip.stop();
var i = sec-1;
var t = setInterval(function () {
if (i <= 0) {
clearInterval(t);
trace("cleared");
clip.gotoAndPlay(3);
clip.vidPlayer_1.playVideo()
}
i--;
trace("i = "+i);
}, 1000);
};
// action on frame of main timeline -
stop();
pauser(_root.welcome, 5);
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
|