0

我编写了一个循环,将 MouseEVENT.CLICK 事件侦听器添加到我视图中的所有图像。

(这部分有效)

var numChildren:int = PageScroll.numChildren; 

for (var i:int = 0; i < numChildren; i++) { 
    if(PageScroll.getChildAt(i) is Image)
    { 
        PageScroll.getChildAt(i).addEventListener(MouseEvent.CLICK, onClick);
    }
}

现在我希望 onClick 在我点击的目标上播放动画......

我不知道该怎么做,也无法通过谷歌找到它......

protected function onClick(event:MouseEvent):void
{
    maxSize.play(new Array(event.target), false);
}

(这部分不起作用)

4

1 回答 1

0

检查此代码;这会帮助你...

<mx:Canvas id="can" width="500" height="500">
        <mx:Image source="indian cricket logo.png"/>
</mx:Canvas>
<mx:Resize id="resize" widthBy="50" heightBy="50" duration="500"/>


protected function application1_creationCompleteHandler(event:FlexEvent):void
    {
        for (var i:int = 0; i< can.numChildren;i++){
            if(can.getChildAt(i) as Image){
                        Image(can.getChildAt(i)).addEventListener(MouseEvent.CLICK,onMouseCLick,false,0,true);
                  }
          }

    }

private function onMouseCLick(e:MouseEvent):void
{
    resize.play([e.currentTarget]);
}
于 2012-05-15T13:15:21.257 回答