Play/Pause Btn in AS2

Out of context: Reply #4

  • Started
  • Last post
  • 4 Responses
  • 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);

    }

View thread