Apache flex Flex:如何设置目标I';你点击了吗?
我编写了一个循环,将MouseEVENT.CLICK事件侦听器添加到视图中的所有图像中 (本部分有效)Apache flex Flex:如何设置目标I';你点击了吗?,apache-flex,animation,flex4,flex-spark,Apache Flex,Animation,Flex4,Flex Spark,我编写了一个循环,将MouseEVENT.CLICK事件侦听器添加到视图中的所有图像中 (本部分有效) (此部件不工作)检查此代码;这会帮助你 <mx:Canvas id="can" width="500" height="500"> <mx:Image source="indian cricket logo.png"/> </mx:Canvas> <mx:Resize id="resize" widthBy="50" heightBy=
(此部件不工作)检查此代码;这会帮助你
<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]);
}
受保护函数应用程序1\u creationCompleteHandler(事件:FlexEvent):无效
{
for(变量i:int=0;i
使用currentTarget
。还要注意,如果您使用的是Flex 4容器(如标签所示),您可能应该使用getElement
而不是getChild
。如果这是一个图像列表,您似乎正在重新设计轮子:您需要的是list
组件。
protected function onClick(event:MouseEvent):void
{
maxSize.play(new Array(event.target), false);
}
<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]);
}