|
-
[CS3] buttons load on all frames - AS3
I am using AS3.0 and CS3.
I have a button called startmenu_btn in my library that will be used several times on different frames to do different actions. So in frame 1 I created the code to bring it out and apply its function.
Code:
var SIM_btn = new startmenu_btn();
addChild(SIM_btn);
SIM_btn.x = 22
SIM_btn.y = 232
SIM_btn.addEventListener(MouseEvent.CLICK, doSIM_BtnClick01);
function doSIM_BtnClick01(e:MouseEvent):void {
gotoAndPlay("StartSIM");
}
Here's the thing. I want this button to be drawn on Frame 1 only, but when I click it and it takes me to the frame "StartSIM" the button is loaded on that frame also. I was going to post this in the AS3 section, but I know it's gotta be so simple and so noob that it might be best put here?
I just started learning AS3 this weekend and used 2 in the past so this might just be a migration issue for me. Any help would be appreciated and let me know if you need anymore info.
Thanks
-
As with any question there are a couple of answers..
how about in your function.. you do this
SIM_btn.removeMovieClip();
Webpages:
www.winningsolutionsinc.com
-
omg, genious. removeMovieClip is AS2, but the equivilant is removeChild.
So for anyone that wants to know how the story ends....here is the code
Code:
var SIM_btn = new startmenu_btn();
addChild(SIM_btn);
SIM_btn.x = 22
SIM_btn.y = 232
SIM_btn.addEventListener(MouseEvent.CLICK, doSIM_BtnClick01);
function doSIM_BtnClick01(e:MouseEvent):void {
gotoAndPlay("StartSIM");
removeChild(SIM_btn);
}
Works like a charm Hope this helps someone else out in the future.
You can resolve this one
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|