A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Kill Pause function prior to actions exicuting

  1. #1

    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 
    sec 1;
       var 
    MyPause setInterval(function () {
          if (
    == 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 
    this;
        
    this.opened true;
        
    //this._x = _root.navWidth * this.index;
        
    var handler = new Tween(this"_x"easingTypethis._x_root.navWidth this.indexdurationtrue);
        
    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.

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    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

  3. #3
    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 
    sec 1;
        if (
    == 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?

  4. #4
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    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 (
    == 0) {
    clearInterval(MyPause);
    trace("cleared");
    }
    };

    var 
    MyPause setInterval(pauseMC,1000); // 1000=1 sec 

  5. #5
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    here is another method -
    PHP Code:
    _global.pauser = function(clipsec) { 
    trace("pausing "+clip+" for - "+sec+" secs"
        
    clip.stop(); 
        var 
    sec-1
        var 
    setInterval(function () { 
        if (
    <= 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.welcome5); 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center