Play/Pause Btn in AS2

  • Started
  • Last post
  • 4 Responses
  • hiatus

    Looking for a easy AS2 Btn to play and pause my movie, but be able to continue.

    The ones I'm finding either make the movie stop completely or play with easing and shit.

    I want the one btn to be just change from (->) play to (II) stop.

    any links maybe to somehing with a source file for me to take apart and get the idea. Thanks homies.

  • duckseason0

    play_mc.onRelease = function() {
    if (playing) {
    this.gotoAndStop(2);
    playing = false;
    return;
    }
    this.gotoAndStop(1);
    playing = true;
    };

    or something along those lines

  • fyoucher10

    That's about as basic in interactivity as it gets, just build it out yourself.

    Here's a really easy example to understand:

    - Make two buttons and all of their states. If you're looking to just swap icons, just make them the exact same shape and lay one on top of the other.
    - Add whatever code to navigate the SWF, stop(), play(), whatever
    - Then just turn the visibility of the other button on and the current one off. This will also disable it at the same time.

    stop_btn.onRelease = function() : Void {
    stop();
    play_btn._visible = true;
    this._visible = false;
    }

    play_btn.onRelease = function() : Void {
    play();
    stop_btn._visible = true;
    this._visible = false;
    }

  • hiatus0

    I have layer1 with <theShowMC> and a stop(); above it.

    If the playMC and pauseMC are in the theShowMC(different frames/same layer), can't i put:
    on(release){
    gotoAndStop(2);
    this.stop();
    }
    On the pauseMC, and:

    on(release){
    gotoAndStop(1);
    this.play();
    }
    On the playMC.
    And have a whole animation inside another MC within this <theShowMC>

  • fyoucher10

    Sounds like you'd probably end up having scope issues that you'll have a hard time resolving. So do this:

    Don't attach code directly to clips. Instead, give them instance names and use the method describes above, just make sure that the code appears on a frame where the clip is. (Don't put code in frame 1, but the clip doesn't appear until frame 10).

    //Coding example >>>

    myButtonName.onRelease = function () {
    //code goes here
    }

    Give whatever you want to target an instance name as well.
    Here's an explanation of what the scope would be in this sample clip:

    myButtonName.onRelease = function () {

    //The timeline where this code is being held would go to frame 20.
    gotoAndStop(20);

    //This button (myButtonName) would go to frame 2 in it's timeline
    this.gotoAndStop(2);

    //This would target another button in the timeline where this code is being held.
    someOtherButton.gotoAndStop(3);

    //This would go to frame 5 in the clip that's holding this clip that you're in now. It would be one clip/step above where this code is being held.
    _parent.gotoAndStop(5);

    //This would go to a movieclip that's in the parent clip above
    _parent.otherButton.gotoAndStop...

    //This would go to frame 403 in the main timeline
    _root.gotoAndStop(403);

    }