A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [CS3] buttons load on all frames - AS3

  1. #1
    Junior Member
    Join Date
    Mar 2002
    Posts
    27

    [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

  2. #2
    Senior Member
    Join Date
    Mar 2000
    Posts
    116
    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

  3. #3
    Junior Member
    Join Date
    Mar 2002
    Posts
    27
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center