0
votes

I made a movie clip with an animation of a pull-down menu in which 3 buttons appear. The thing is, I'd like for those buttons to send me to an exact frame within the main timeline, and I haven't quite understood how it can be made.

The movieclip is located within a frame inside the main timeline, and its structure is kind of like this one.

The frame "Sucesos" is not within the timeline of the MovieClip, but in the Main Timeline, whereas the Button "IrSucesos1" is located inside a frame within the movie clip. The code I use is this one.

function LinkSucesos1 (event:MouseEvent):void
{ gotoAndStop("Sucesos1"); 
} 
IrSucesos1.addEventListener(MouseEvent.CLICK, LinkSucesos1);

I don't know whether I should put the code inside the timeline of the movieclip or on the main timeline in the frame the movie clip is located, or if the code is the right one.

How do I make the buttons work by sending me to the frame that I want to get to in the main timeline and then have it stop there? What is the code, and where should I put it?

2
Can you post your code?fvrghl
I actually just have the simple one.--- function LinkSucesos1 (event:MouseEvent):void{ gotoAndStop("Sucesos1"); } IrSucesos1.addEventListener(MouseEvent.CLICK, LinkSucesos1);---- The thing is "IrSucesos1" is inside a movieclip, and I don't know whether I should put the code inside the timeline of the movieclip or on the main timeline in the frame the movie clip is located.LuluSensei
You should edit your question to include that.fvrghl
is it alright like that?LuluSensei
Yeah! Thanks for improving your question for the community.fvrghl

2 Answers

1
votes

If I've understood your structure the way I think I have, the following should work. On your main timeline, add a new layer called Actions and on the frame that has the movieclip containing your buttons add a keyframe to this layer. Go to the movieclip that contains the buttons. Open the actions panel and type Stop(). Create a new layer called Button actions, click on the (blank) kayframe on this layer and add the following code:

import flash.events.MouseEvent;

my_button.addEventListener(MouseEvent.CLICK,on_click)

function on_click(e:MouseEvent)
{
    MovieClip(root).gotoAndStop(5)
}

You'll need to change my_button to the button instance you'd like to assign the event listener to and 5 to the frame you want to go to on the main timeline. Test your movie - hopefully this should work for one button. For the others to work, simply give them each their own event listener and function to do what you want them to (ask if you get lost!).

0
votes

stage is available anywhere where the displayObject is linked to the stage. You can give a reference object to that control button. Your timeline object won't change so its fine.