A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: addChild() to a container error

  1. #1
    Junior Member
    Join Date
    Apr 2009
    Posts
    15

    addChild() to a container error

    Hi,

    I created a about_mc, which works like a button. The button is placed on stage1. When I click it, i want it to call another movie from the library and play it.So code inside the about_mc button on frame 1:
    var dynAbout = textAbout();
    addChild(dynAbout);
    it works fine up to here. Now i would like to access the dynAbout, so I will add name to it:
    dynAbout.name="dynNameAbout";
    then accessing it like that:
    MovieClip(parent.root).dynNameAbout.x=300;

    When I test it, I get the textAbout() movie added to the scene1 and its playing, but it pops up with an error:
    TypeError: Error #1010: A term is undefined and has no properties.
    at About/aboutDOWN()

    I'm pretty sure that I'm accessing it the wrong way, how should I do it? Pls explain in steps, its my like 1st week of AS

    thanks!
    Polish

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    MovieClip(parent.root).getChildByName("dynNameAbou t").x=300;
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Junior Member
    Join Date
    Apr 2009
    Posts
    15
    Quote Originally Posted by cancerinform View Post
    MovieClip(parent.root).getChildByName("dynNameAbou t").x=300;
    Hi,
    That created different error as well, but when i just did
    getChildByName("dynNameAbout").x=300
    it worked fine, i better go back and read more :/

    thanks for help

  4. #4
    Junior Member
    Join Date
    Apr 2009
    Posts
    15
    cancerinform,
    MovieClip(parent.root).getChildByName("dynNameAbou t").x=300;

    how do I access getChildByName("dynNameAbout") TimeLine? its a movieclip. I need to move it to frame 2. Tried so many ways, but i'm failing to access the timeline.
    I can access all properties and change them ok, but if I do:

    MovieClip(parent.root).getChildByName("dynNameAbou t").gotoAndStop(2);
    compiler errors pop up

    thanks

  5. #5
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Try this:
    MovieClip(getChildByName("dynNameAbout")).gotoAndS top(2);
    - The right of the People to create Flash movies shall not be infringed. -

  6. #6
    Junior Member
    Join Date
    Apr 2009
    Posts
    15
    thanks cancerinform
    it worked, I had to go one level up as well.
    MovieClip(parent.getChildByName("nameSPC")).gotoAn dStop(1);
    also, I've managed get it getChildAt(). Looks like it's working, funny enough I needed a day of rest to clear my mind

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