Flex:为什么我不能得到显示对象的子子?

时间:2009-10-13 20:09:12

标签: flex

我在访问displayObject的子子时遇到问题。这是我的代码:private

function resizeTag(event:MouseEvent):void{
            var currTagPos:Number = 1; 
            var theTagBox:DisplayObject = tagCanvas.getChildAt(currTagPos); //i have confirmed that it exists on the stage and has sub-children

            trace(theTagBox.getChildAt(0).width);
        }

基本上我想要得到:

tagCanvas.getChildAt(currTagPos).getChildAt(0).width;

但它不起作用。感谢您提供的任何指导:)

1 个答案:

答案 0 :(得分:2)

看起来我需要将其称为DisplayObjectContainer。我这样做了:

trace((tagCanvas.getChildByName(currTagName) as Canvas).getChildAt(3) as Button);

我发现这篇文章帮助我解决了这个问题: http://www.nabble.com/undefined-method-getChildAt-td19812715.html