# Navigation help

**URL:** https://forum.kirupa.com/t/navigation-help/260982
**Category:** Uncategorized
**Created:** [May 21, 2008, 6:16pm UTC](https://forum.kirupa.com/t/navigation-help/260982 "2008-05-21T18:16:31Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![afshean](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@afshean](https://forum.kirupa.com/u/afshean)
#### Post date: [May 21, 2008, 6:16pm UTC](https://forum.kirupa.com/t/navigation-help/260982/1 "2008-05-21T18:16:31Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![doridori](https://avatars.discourse-cdn.com/v4/letter/d/3da27b/32.png) [@doridori](https://forum.kirupa.com/u/doridori)
#### Post date: [May 21, 2008, 8:12pm UTC](https://forum.kirupa.com/t/navigation-help/260982/2 "2008-05-21T20:12:34Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![snickelfritz](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@snickelfritz](https://forum.kirupa.com/u/snickelfritz)
#### Post date: [May 21, 2008, 9:54pm UTC](https://forum.kirupa.com/t/navigation-help/260982/3 "2008-05-21T21:54:40Z")

</div>

[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]

```auto

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);
}

```
