Navigation help

hello

this is my first time posting a question in a forum and I just started making my first website with flash cs3.

I have a main timeline with a movieclip on stage called mc_1 and inside this movieclip is another movie clip called mc_2 that is acting as a button.

I want to use mc_2 to go to the main timeline and jump on frame labeled “video”

this is the action I have on the mc_2

import flash.events.MouseEvent;
var thisParent:DisplayObject = (this.parent);

mc_2.addEventListener(MouseEvent.CLICK, onClick);

function onClick(event:MouseEvent):void {
this.gotoAndPlay(“video”);
}
mirim_mc.buttonMode = true;

I don’t get an error but it doesn’t work.

The code structure looks correct, which is also why you’re not getting an error.

The error lies within your referencing.
You actually have part of the solution in your code, but it looks like you forgot to finish it.

The problem is that we in this code are inside mc_1.
You want to gotoAndPlay in the main timeline.
When you call this.gotoAndPlay you are telling Flash to go to a frame in this, which in this case is mc_1. What you need to do is somehow reference the main timeline, which in this case is a parent of this(mc_1).

So in this case you could reference this.parent to reach the main timeline.
The thing is you already create this reference on the second line of your code.
var thisParentisplayObject = (this.parent);
So we can actually use this.

thisParent.gotoAndPlay(“video”); which will call gotoAndPlay on the parent object of mc_1 = main timeline.

You can also reference the main timeline object through Object(root).
Object(root).gotoAndPlay(“video”);
This might confuse things though if the current .swf is embedded in a parent .swf.

This should solve your problem, provided I understood your problem correctly :).
Good luck!
**
edit:
**Ow. Typography looks really messed up in this post. Hope you can read it.

[list][]Your button is a movieclip, instance name: “mc_2”
[
]Button “mc_2” is nested within a movieclip, instance name: “mc_1”
(I think I would change this to something more descriptive like “buttonGroup”)
[]Frame label for the frame targeted by “mc_2” should also be “mc_2”
[
]Target the parent movieclip with your event listener; events will naturally propagate to all children of this parent.
This allows you to add as many buttons as needed without requiring additional event listeners.[/list]


stop();
import flash.events.MouseEvent;
var buttonAndFrame:String = "";

mc_1.addEventListener(MouseEvent.CLICK, onClick, false, 0, true);

function onClick(event:MouseEvent):void {
buttonAndFrame = event.target.name;
    trace(buttonAndFrame);
    gotoAndPlay(buttonAndFrame);
}