addChild 는 한개의 오브젝트에만 가능하다
ActionScript 3 2007. 6. 4. 11:01 |var sp1:Sprite = new Sprite();
addChild(sp1);
var sp2:Sprite = new Sprite();
addChild(sp2);
sp2.y = 400
var shape:Shape = new Shape();
shape.graphics.beginFill(0xFFFF00);
shape.graphics.drawCircle(0, 0, 200);
sp1.addChild(shape);
sp2.addChild(shape);
두개의 DisplayObject 클래스를 화면에 올려놓고 또하나의 DisplayObject 클래스를 만들어 집어넣어보았다.
그냥 단순한 생각으로는 두군데 모두 들어가야 맞다고 생각했으나 그게 아니었다. DisplayObject 클래스에는 clone 메소드도 없으니 결국 new 로 새 DisplayObject 를 생성해야 한다.
sp1 과 sp2에서 shape 를 참조하는게 아니라 shape 에서 자신이 addChild 된 DisplayObject 클래스를 찾는 것일까?
생각해 볼 문제다.
'ActionScript 3' 카테고리의 다른 글
as3으로 기본 메뉴 만들기 (0) | 2007.06.11 |
---|---|
removeChild 는 완전한 삭제가 아니다. (0) | 2007.06.08 |
navigateToURL target 의 기본값은 _blank 다 (0) | 2007.06.01 |
buttonMode (0) | 2007.05.28 |
new TextField 의 기본 width, height 값은 100이다 (0) | 2007.05.21 |