Search code examples
actionscript-3flash-cs4

Instance name not working


My code looks like this

var newFrame:MovieClip = new MovieClip();
newFrame.graphics.lineStyle(lineWidth, xmlData.config.frame.@color);
newFrame.graphics.beginFill(0x000000, 0);
newFrame.graphics.drawRect(0, 0, stage.stageWidth+2, stage.stageHeight+2);
newFrame.graphics.endFill();
newFrame.name = "movieFrame";
addChild(newFrame);

So far everything is OK but later on

addChildAt(textClip,3);
addChildAt(thumbClip,4);
addChildAt(menu,5);
addChildAt(movieFrame,6);

Last line gives an errormessage: 1120: Access of undefined property movieFrame.


Solution

  • OK this is what I did to get things to work. I added empty movieclip in the main timeline and gave instance name "movieFrame". Now the code is almost same than in the original posting.

    var newFrame:MovieClip = new MovieClip();
    newFrame.graphics.lineStyle(lineWidth, xmlData.config.frame.@color);
    newFrame.graphics.beginFill(0x000000, 0);
    newFrame.graphics.drawRect(0, 0, stage.stageWidth+2, stage.stageHeight+2);
    newFrame.graphics.endFill();
    movieFrame.addChild(newFrame);
    

    And now all the addChildAt commands work OK. Thanks for helping me to get on the right rail once again.