Skip to main content
Participant
November 24, 2013
Answered

"Skip Intro" Button Issue

  • November 24, 2013
  • 1 reply
  • 1104 views

I have a layer containing a button named "Skip" that holds the code:

Skip.addEventListener(MouseEvent.CLICK,releaseHandler);

function releaseHandler(e:MouseEvent):void {

gotoAndPlay(153);

}

I would like the skip button to go to and play frame 153, but this code only makes it go to the frame of that specific layer. However, I have all the other animated elements in movieclips inside of seperate layers. Before I had them in seperate layers but without each being a movieclip, and the button worked fine, but now how can I change the code to reflect the changes I made?

This topic has been closed for replies.
Correct answer kglad

I tried that as well before, but it returned me with a 1120: Access of undefined property. The code is placed within a movieclip within a movieclip and the movieclips that are being addressed are all on the main timeline, so I tried the MovieClip(this.parent.parent).gotoAndPlay(153) as well as MovieClip(this.parent.parent).movieclipname.gotoAndPlay(153) and still didn't get it to work.


you need to know either the path from timeline that contains your code to the movieclip timeline that you want to control or from the main timeline to your movieclip timeline that you want to control.

so, if the movieclip you want to control is on the main timeline and has instance name mc, this code will work from any timeline:

MovieClip(root).mc.gotoAndPlay(153);

this is not good coding and will only work if mc exists when the code executes.

1 reply

kglad
Community Expert
Community Expert
November 24, 2013

that code should still work, but you can't test movieclips by scrubbing the timeline. use the test environment (ctrl-enter, by default).

Participant
November 24, 2013

I tested it in both Flash and HTML since it's the button that needs correcting. I'll give a simple rundown if it'll help:

Let's say I have my skip button on layer one and a movieclip that has an animation of a square moving from the left side to the right side on layer two. In my situation, the code I currently have only plays frame 153 of the "skip button layer" and not the square layer which I want it to. But let's say I go into the movie clip and copy and paste the layer out so that it's part of the main timeline, that's when the button works, however I need it to be a movieclip for independent animations and that's why I need the correction.

I tried adding event listeners to all other movieclips but the button still isn't doing anything, I tried the MovieClip(root) and (parent) codes too without any results.

Message was edited by: LessHeroes

kglad
Community Expert
Community Expert
November 24, 2013

i'm not sure what you're seeing but your analysis of what's occuring is incorrect: all layers are played (though guide layers are handled differntly than all other layers).  layers don't even exist in the swf.  they are just used for depth ordering of on-stage objects and a few other things.

if your movieclip is on a keyframe (in any layer) at frame 153 you will see your movieclip's timeline play (under typical circumstances).