Skip to main content
Participant
September 15, 2010
Answered

Help on Flash Navigation

  • September 15, 2010
  • 1 reply
  • 737 views

Could anyone help me out with this?

I have a button that is buryed in an "movie" object and I cannot get it to go to a labeled frame on the main movie timeline.  I have used the code below in the past, but its not working.

Anyone?

I have named the instance of the button "CLbtn"

this.CLbtn.addEventListener(MouseEvent.CLICK,CLbtnClick);

function CLbtnClick(event:MouseEvent):void {

(parent as MovieClip).gotoAndPlay("top");

}

This topic has been closed for replies.
Correct answer Plystire

You were correct, it is not referencing the stage, it is referencing [object NE_24]

Now, how do I get it to reference the stage?
Thanks so much, really appreciate this!

Hmmm, I'm not sure what an NE_24 object is exactly.

Can you access the stage directly? Instead of using "(parent as MovieClip)" try just using "stage" in its place. So it would look like:

stage.gotoAndPlay("top");

If that doesn't work, then maybe you can reach the stage from the NE_24 by accessing its parent.

If you go that route let me know what these traces return, so we can see if you can find the stage that way:

trace(parent.parent);

trace(parent.parent.parent);

I've had instances where I've needed to do this to reach back to the stage (when the stage was not directly accessible)

[EDIT]

Just so I am clear in understanding what you want. You are trying to play the main timeline, correct? Or are you trying to play the timeline of a movieclip that is on the stage?

If you're trying to play the timeline of a movieclip on the stage then we'll be looking for a "object MovieClip" instead of "object Stage" in the parent structure.

~Plystire

Message was edited by: Plystire

1 reply

Inspiring
September 15, 2010

Ensure that the "parent" you're referencing is the stage. You said that the code is contained within a nested movie, correct? Perhaps the parent you're referencing is not the object you think it is.

trace(parent);

Use that above your gotoAndPlay line and ensure it returns "[object Stage]" in the output.

~Plystire

Participant
September 15, 2010

Sorry if this is an dumb question....but where exactly do you put that "trace(parent);" and how do you go about seeing what it responds?  I have never run something like that and needed to see the script answer something.

Inspiring
September 15, 2010

Here, I've copied your code and placed the trace where it should be.

this.CLbtn.addEventListener(MouseEvent.CLICK,CLbtnClick);

function CLbtnClick(event:MouseEvent):void {

trace(parent);

(parent as MovieClip).gotoAndPlay("top");

}

In order to have your main timeline play, the "gotoAndPlay" function must be called on the stage (that's what I recall anyway), so what this trace command will do is help you find out if you're calling the function on the stage or not.

When the trace command is used, the information it was told to trace will end up in the Output box in your Flash editor. It's very handy for showing information while the project is running.

~Plystire