0
votes

i have made a movie clip with some buttons inside. The idea behind this was to allow a scrolling system to be used. The only problem is i can't seem to figure out how to link a button inside a movie clip with a frame from outside of the movie clip and on the main stage.

My code atm is:

stop();
import flash.events.MouseEvent;

sports1.addEventListener(MouseEvent.CLICK,sport1)

function sport1(e:MouseEvent)

{
    MovieClip(root).gotoAndStop(sports)
}

What i would like to happen is that each button inside the movie clip will take me to a certain frame on the main stage, like a navigation system. I am really new to flash so i may not understand all the technical terms yet, so be easy on me :)

1
gotoAndStop(sports) won't work because sports seems to be undefined. Is 'sports' the name of a frameLabel? Try wrapping it in quotations to make it a String.Karmacon
Sorry in my code i have used quotations, i get this error message: TypeError: Error #1009: Cannot access a property or method of a null object reference. at app_Scene1_fla::MainTimeline/eScrollDown1()[app_Scene1_fla.MainTimeline::frame5:38] I heard this will only work in AS2 :(Shaun
The error is coming from the Main Timeline at frame 5, line 38 in a function called eScrollDown1()Karmacon
im not sure thats the problem as when i remove the button code, it works completely fineShaun

1 Answers

0
votes

So if you are creating a Main Movie Clip on the Stage and have inner Movie Clips that are acting as buttons. You want those inner buttons to take you to different frames on the main stage when the user interacts with them.

This is how you would do so.

What you would need to do as you already done give the Main Movie clip holding the inner buttons an instance name sports1 any inner button would also need an instance name say a button has an instance name of mcButton to access that button you would need to call on it like so:

sports1.mcButton.addEventListener(MouseEvent.CLICK,sport1)
sports1.mcButton.buttonMode = true;

then if you want that button when clicked to go to frame 2 on the main stage you would simply do this in the sport1function:

function sport1(e:MouseEvent):void 
{
      gotoAndStop(2);
}

I threw in the sports1.mcButton.buttonMode = true; that way it shows that it is interactive ie click able