A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Pausing a movieclip and jumping to a framelabel in the parent swf

  1. #1
    Junior Member
    Join Date
    Jan 2008
    Posts
    17

    Post Pausing a movieclip and jumping to a framelabel in the parent swf

    Hi

    I need a little help with the code below. This is the predicament I’m in.

    I have 3 files:

    Launch.exe
    video.swf
    pause.swf

    In the launch.exe, I have a ‘loadmovie’ command which loads the external file ‘video.swf’.
    When the video is loaded, I want the viewer to be able to hit the SPACEBAR at any time which will result in pausing the video (pause.swf appears on screen) and after 3 seconds unloads the video.swf file and jumps to a frame label on the ‘Launch.exe’ timeline.

    The code below is what I have at the moment but it doesn’t work.

    Anybody have any suggestions?


    pause_icon._visible = false;

    var keyListener:Object = new Object();
    Key.addListener(keyListener);

    keyListener.onKeyUp = function(){
    if(Key.getCode() == 32){ // SPACE key
    video_ad.stop(); // substitute your movieclip name
    pause_icon._visible = true;
    var sto = setTimeout(moveAlong, 3000);
    loadMovie("assets/pause.swf", 95);

    }
    }

    function moveAlong(){
    pause_icon._visible = false;
    _root.myExternalSWF.gotoAndStop ("home_promotions");
    unloadMovie(90);

    }

  2. #2
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    so whats the problem?

    what is currently happening..or not happening?

    why are you externally loading a .swf for this 'pause' screen?

    why not just have a movieClip in the library that you attach when you hit the spacebar?

    your way you need to load the .swf.. (which if you are using an .exe must mean the files are local? so maybe not a big deal) takes some time.. and then you need ot trigger or test for a way to know when the pause.swf is loaded.. and then at that point..start your 3 second time.

    anyways.. I also suggest you NOT use loadMovie() any more..its old..and for AS2 using a movieClip Loader instance is the best way to go.. you get more control of executing other actions during different states of your loading of content..


    anyways.. try this (not tested)

    it loads your video.swf clip in..

    when you hit space bar.. it will load your pause.swf in..

    count 3 seconds..

    remove the video.swf
    remove the pause.swf
    and jump to specified frame in the _root timeline..


    actionscript Code:
    //movieClip loader instance to load the video.swf
    var videoLoader:MovieClipLoader = new MovieClipLoader();
    var videoListener:Object = new Object();

    videoListener.onLoadStart = function(target_mc:MovieClip):Void {
        trace(">> videoListener.onLoadStart()");
    }
    videoListener.onLoadProgress = function(target_mc:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void {
        trace(">> videoListener.onLoadProgress()");
    }
    videoListener.onLoadComplete = function(target_mc:MovieClip, httpStatus:Number):Void  {
        trace(">> videoListener.onLoadComplete()");
    };
    videoListener.onLoadInit = function(target_mc:MovieClip):Void  {
        trace(">> videoListener.onLoadInit()");
    };
    videoLoader.addListener(videoListener);

    // create an empty movieClip on the stage to hold our content...(this can be any target you want though)
    var videoContainerClip:MovieClip = this.createEmptyMovieClip("videoContainerClip", this.getNextHighestDepth());
    //load the video.swf/content
    //videoLoader.loadClip("someVideo.swf", videoContainerClip);

    //-----------------------------------------------------------------------------------//

    //pauseClip loader instance to load the pause.swf
    var pauseLoader:MovieClipLoader = new MovieClipLoader();
    var pauseListener:Object = new Object();

    pauseListener.onLoadStart = function(target_mc:MovieClip):Void {
        trace(">> pauseListener.onLoadStart()");
    }
    pauseListener.onLoadProgress = function(target_mc:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void {
        trace(">> pauseListener.onLoadProgress()");
    }
    pauseListener.onLoadComplete = function(target_mc:MovieClip, httpStatus:Number):Void  {
        trace(">> pauseListener.onLoadComplete()");
    };
    pauseListener.onLoadInit = function(target_mc:MovieClip):Void  {
        trace(">> pauseListener.onLoadInit()");
        //count 3 seconds then remove video, and jump to new frame
        setTimeout(pauseTimer,3000);
    };
    pauseLoader.addListener(pauseListener);

    // create an empty movieClip on the stage to hold our content...(this can be any target you want though)
    var pauseContainerClip:MovieClip = this.createEmptyMovieClip("pauseContainerClip", this.getNextHighestDepth());
     

    //-----------------------------------------------------------------------------------//

    //listen for the spacebar to execute a function
    var keyListener_obj:Object = new Object();
    keyListener_obj.onKeyDown = function() {
        switch (Key.getCode()) {
            case Key.SPACE :
                trace("SPACE BAR HIT");
                //load the video.swf/content
                pauseLoader.loadClip("pause.swf", pauseContainerClip);
                break;
            default :
                //trace("ANY OTHER KEY PRESSED (DEFAULT ACTION IF NEEDED)");
                break;
        }
    };
    Key.addListener(keyListener_obj);

    function pauseTimer(){
        trace("FIRED");
        //unload video.swf
        videoContainerClip.unloadMovie();
        //unload pause.swf
        pauseContainerClip.unloadMovie();
        //jump to parent frame
        _root.gotoAndPlay(3333);   
    }

    good luck..

  3. #3
    Junior Member
    Join Date
    Jan 2008
    Posts
    17
    Thank you very much for your reply.
    I implemented your code. We are very close but no cigar.
    I can get the video playing no problem but when I hit the spacebar, the video doesn't pause and the 'pause.swf doesn't appear. It doesn't either jump to the timeline in the root swf.
    Any suggestions would be gratefull.

    Thanks

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