dcsimg
A Flash Developer Resource Site

Page 2 of 2 FirstFirst 12
Results 21 to 26 of 26

Thread: How to use addChild from other class

  1. #21
    absolutezero3424
    Join Date
    Nov 2006
    Posts
    508
    Cancerinform:

    yes, I was extending the "other" class as MovieClip, and I extended the Main class similarly!

  2. #22
    Flash/Flex Developer samac1068's Avatar
    Join Date
    Apr 2007
    Location
    Here, no there
    Posts
    1,813

    If I understand this correctly.....

    I would first place the library object on the stage....THEN I would assign the new class? HUH?

    I have serveral buttons to place on the stage, and don't want to do them "manually", so I have this.

    Code:
    var MCname:Object = getDefinitionByName(interData.element[a].name);
    var tempbutton = this[interData.element[a].name];
    tempbutton = new MCname();
    tempbutton.x = interData.element[a].x;
    tempbutton.y = interData.element[a].y;
    this.addChild(new NavButton(tempbutton));
    I don't get any buttons on the screen using this. However, if I change the last line to
    Code:
    this.addChild(tempbutton);
    I get the buttons, but the NavButton class isn't able to provide the control (of course). I need that control and I need to the ability to identify each button separately so I can perform different actions when they are clicked.

    I may be making this harder than it should be, but I can't get my head to stop swimming....any help?
    Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.

  3. #23
    absolutezero3424
    Join Date
    Nov 2006
    Posts
    508
    well, I don't know how all your project is structured, but if you're saying that the:

    this.addChild(tempbutton);

    ...if that works from your other class and the tempbutton is displayed, then your issue is different from my issue and there would probably be something wrong with the way you are using the NavButton class. Have you tried this:

    Code:
    //....other code
    
    var myBtn:NavButton = new NavButton();
    this.addChild(myBtn);
    
    //....more code
    you may need to add an argument to your NavButton() constructor function to suit your needs, but that should work, at least according to the original issue.

  4. #24
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Ok,

    in the future:

    1. don't continue such old thread and mix up topics.
    2. give more information. The three lines of code don't tell very much.
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  5. #25
    absolutezero3424
    Join Date
    Nov 2006
    Posts
    508
    Quote Originally Posted by cancerinform
    Ok,

    in the future:

    1. don't continue such old thread and mix up topics.
    2. give more information. The three lines of code don't tell very much.
    I thought it was better to reuse a previous thread that pertained to the topic? Also, which code were you referring to?

  6. #26
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    I was making a general statement and addressing everybody who continued this thread.

    Unless it is a sticky for resources as a general rule if you don't find a thread by search, which shows the solution you want, start a new one.
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

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