dcsimg
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: A term is undefined - how to reference flash-created MCs in the displaylist

  1. #1
    Member
    Join Date
    Mar 2004
    Posts
    51

    A term is undefined - how to reference flash-created MCs in the displaylist

    OK, so I've got a movieclip created in Flash that has 8 children, each movieclips, called "navButton01"-"navButton08". The containing movieclip is called navBar_mc.

    My original code had the script adding the child navBar_mc to the root of the file. This caused all sorts of overlapping problems when the movieclips were removed and re-added. So I've created containers for my different layers, each called "somethingHOLDER" at each placed at a specific depth on the displaylist so as to prevent re-arrangement.

    However, once I add the children to the container you don't need to reference the container when referencing the child. For example, this works:

    Code:
    			menuHOLDER.addChild(navbar_mc)
    			navbar_mc.x=516.1;
    			navbar_mc.y=519.1;
    While this throws a "Error #1010: A term is undefined and has no properties."

    Code:
    			menuHOLDER.addChild(navbar_mc)
    			menuHOLDER.navbar_mc.x=516.1;
    			menuHOLDER.navbar_mc.y=519.1;
    OK, so I don't need to reference the container when I want to talk to the child. Great, right? Except, this command won't work (but doesn't throw an error):

    Code:
    navBar_mc.navButton01.alpha=0;
    While this throws the same error:

    Code:
    menuHOLDER.navBar_mc.navButton01.alpha=0;
    So how do I command flash-created children of displaylist-added children?

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    You can use getChildByName to access display children by instancename.

    Code:
    var nb1:MovieClip = MovieClip(navBar_mc.getChildByName("navButton01"));
    nb1.alpha = 0;

  3. #3
    Member
    Join Date
    Mar 2004
    Posts
    51
    Hmmm - that doesn't seem to be working - I don't get the error but it still doesn't change their alpha.

    Can I use child commands on children that were added in the Flash UI but not with AS3 displaylist coding?

  4. #4
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    If that code threw no errors, then it successfully accessed a movieclip and set its alpha property to 0. It may not be the movieclip you think it should be, but it did something. Or that code was never executed.

    I have no idea what your last question means. The only thing that the flash ui does for you that is different than straight up coding is it automatically declares variables based on instancenames, and takes things off/puts things on stage across frames.

  5. #5
    Member
    Join Date
    Mar 2004
    Posts
    51
    Well I was able to fix it - I don't have to do anything different even though I added navbar_mc as a child of another movie clip, the dot syntax remains the same. Thanks for your help!

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