As3 flash button in a movie clip - actionscript-3

all I am trying to get a button I placed inside a movie clip to change the scene on my main timeline.
this is what I have right now:
on the main timeline,
the scene that has the movie clip is called (girl_tone_control) and the scene that I want to go to is called (girl_outfit_v1)
inside the movie clip on (girl_tone_control), I have a button on a frame with the instant name letsgo_btn.
I then have another layer in the same movie clip as the button called actions
with this code
import flash.events.MouseEvent;
letsgo_btn.addEventListener(MouseEvent.CLICK, letsgo1);
function letsgo1(e:MouseEvent):void
{
MovieClip(root).gotoAndPlay(1,'girl_outfit_v1');
}
I don't know if this is correct every time I test it out hoping to go to scene (girl_outfit_v1) it doesn't work and I get the error
ArgumentError: Error #2108: Scene girl_outfit_v1 was not found.
at flash.display::MovieClip/gotoAndPlay()
at wwe2_girl_tone_control_fla::girl_select_1/letsgo1()
can anyone help?

I would advice you to double check the scene name as it must work, or attach your fla to let me check what's wrong

Related

AS3 movie instance turning null

I'm banging my head on what seems like a simple as3 problem. I have a flash chart that contains a series of buttons that go to different parts of the timeline on Roll_over.
so for example - the "Market maneuvers" button looks like this
marketManeuversButton.addEventListener(MouseEvent.ROLL_OVER, marketManeuversButtonReaction)
and the function it calls looks like this
function marketManeuversButtonReaction (event:MouseEvent):void{ gotoAndStop('18'); }
The problem is, when I mouseover that button (and many others), it goes to frame '18' and then throws this error:
Error #1009 Cannot access a property or method of a null object
reference
here is my flash file
Any help would be appreciated. Thanks.
When you change frame, flash recreated all objects in frame, and you loose all your data.
Yes, it's simple AS3 problem, just don't use a scene frames at all. Program all in classes, don't use any frames to code any logic except stop(), gotoAndStop(), gotoAndPlay().
In your problem, put all scene in movieclip, exclude control buttons from it to another movieclip and control scene movie clip with control movieclip >____<. It pegleg. Next time just do it right, don't use scene frames.

how do I link a button inside a movie clip into the mainframe (flash CS6 AS3)

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 :)
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

How can I make a button inside a Movieclip send me to a frame in the main timeline?

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?
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!).
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.

Targeting Root from a Movieclip

Im having trouble targeting back to the main timeline from within a movie clip AS3.
I have tried the code below but still does nothing? I have labelled the frame in which I would like it to go to on the main time and added this code to the actions within in the movie clip, but when I click the button it does nothing? I have no errors come up?
Any ideas?
map_UK.addEventListener(MouseEvent.CLICK, MAIN);
function MAIN(e:MouseEvent):void
{
MovieClip(root).gotoAndPlay("MAIN");
}

add movie clip on the second frame with as3

how can i add a movie clip on a specific frame using addChild called in a class with AS3 ,
my problem is how access to the specific frame
thank you
The tricky thing about this would be to handle the frame 'live cycle'...
The way I would do it, is:
Add an event listener for FRAME_CONSTRUCTED
Send your movieclip and stop it at your desired frame.
Attach your symbol on the handler of the event.
Something like this:
mc.addEventListener(Event.FRAME_CONSTRUCTED, _addChild );
mc.gotoAndStop(2);
function _addChild(e:Event):void{
mc.addChild( new Square) //Library symbol
}