Please consider the following:
class Engine extends Sprite
{
function Engine():void
{
this.addChild(new MyObj());
}
}
class MyObj extends Sprite
{
public var myVar:uint = 197;
public function MyObj():void
{
this.name = "OBJECT_1";
}
}
And then if i try to do this in Engine.as constructor after adding child:
trace(this.getChildByName("OBJECT_1").myVar);
it prints an error saying "Acess of possibly undefined..."
What i want to know is if it's possible to acess a var of a child, without making a var for that child (like "private var obj:MyObj = new MyObj();", and then using "obj.myVar") without using the static keyword, because that will make the var "myVar" belong to the class, and not the instance, and that's not what i want.
Hope you understand what i meant, cuz it's kinda messy...
Thanks in advance
AS3 Acessing Child's Vars
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement