我写了一个循环,将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);
}
(这部分不起作用)
答案 0 :(得分: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]);
}