2013-02-07 4 views
1

의 다음과 같이 내가 몇 가지 기본 MXML 설치 있다고 가정 해 봅시다 : 나는 (손자로 참조하여 이미지 요소의 속성을 참조 할 수 있습니다 어떻게액션 참조 (자식의 자식) 요소

<Item id="parent"> 
    <Frame> 
     <mx:Image/> 
    </Frame> 
</Item> 

을 아이의 아이)의 부모 항목? 나는 getChildAt()에 데이지 체인 두 통화를 시도했습니다, 즉 :

parent.getChildAt(0).getChildAt(0) 

그러나 나는 다음과 같은 오류 얻을 : 손자 요소에 전화를 걸 수있는 적절한 방법을 무엇

Error: Call to a possibly undefined method getChildAt through a reference with static type flash.display:DisplayObject. 

을 ?

+0

'MovieClip'으로 캐스팅해야 할 수도 있습니다. – David

답변

2

getChildAt() 기능은 다음과 같이

getChildAt()

그래서 당신이 타입 캐스팅을해야 DisplayObject 인에게 반환한다.

DisplayObjectContainer(parent.getChildAt(0)).getChildAt(0) 
+0

감사합니다.이 기능은 훌륭했습니다. 이제 오류의 의미를 이해합니다. ;-) – Tyler