문제

Let's say I have some basic MXML setup as follows:

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

How can I refer to an attribute of the Image element by referring to it as a grandchild (child of a child) of the parent Item? I've tried daisy-chaining two calls to getChildAt(), i.e.:

parent.getChildAt(0).getChildAt(0)

But I get the following error:

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

What is the proper way to make a call to a grandchild element?

도움이 되었습니까?

해결책

getChildAt() function returns a DisplayObject

getChildAt()

So you must be type cast as follows.

DisplayObjectContainer(parent.getChildAt(0)).getChildAt(0)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top