Hi.
How am I supposed to address a shape within a sprite within a sprite?
This code doesn’t work, so how is it supposed to be done?
package classes {
import flash.display.Sprite;
import flash.display.Shape;
import flash.display.DisplayObject;
public class Test extends Sprite {
public function Test() {
var container:Sprite = new Sprite();
var sprite:Sprite = new Sprite();
var shape:Shape = new Shape();
sprite.name = 'sprite';
shape.name = 'shape';
this.addChild(container);
container.addChild(sprite);
sprite.addChild(shape);
var object1:DisplayObject = container.getChildByName('sprite');
var object2:DisplayObject = object1.getChildByName('shape');
trace(object1); // Working
trace(object2); // Error...
}
}
}
This produces the following error:
1061: Call to a possibly undefined method getChildByName through a reference with static type flash.display:DisplayObject.
I miss the AS2 path structure, like _root.container.sprite.shape._visible = false;
How do I do this in AS3?
/ Frank