组件:imgBox.mxml <? xml version="1.0" encoding="utf-8" ?> < mx:Canvas xmlns:mx ="http://www.adobe.com/2006/mxml" width ="400" height ="300" > <!-- 元数据标签 --> < mx:Metadata > <!-- 为事件和效果触发器定义数据 --> [Event(name="hideImage",type="flash.events.Event")] [Event(name="showImage",type="flash.events.Event")] <!-- 将事件和效果联系起来 --> [Effect(name="hideImageEffect",event="hideImage")] [Effect(name="showImageEffect",event="showImage")] </ mx:Metadata > < mx:Script > <![CDATA[ internal function doDown():void{ this.dispatchEvent(new Event("hideImage")); //派发事件 } internal function doUp():void{ this.dispatchEvent(new Event("showImage")); //派发事件 } ]]> </ mx:Script > < mx:Image x ="108" y ="0" source ="img/5.jpg" width ="292" height ="300" id ="img" mouseDown ="doDown()" mouseUp ="doUp()" /> </ mx:Canvas > imgBoxIris.mxml <? xml version="1.0" encoding="utf-8" ?> < mx:Application xmlns:mx ="http://www.adobe.com/2006/mxml" layout ="absolute" xmlns:tree ="tree.*" > < tree:NewIrisEffect id ="myIris1" position ="leftTop" scaleXFrom ="0.1" scaleXTo ="1" duration ="2000" ></ tree:NewIrisEffect > < tree:NewIrisEffect id ="myIris2" position ="rightBottom" scaleXFrom ="1" scaleXTo ="0.1" duration ="2000" ></ tree:NewIrisEffect > < tree:imgBox x ="29" y ="20" showImageEffect ="myIris1" hideImageEffect ="myIris2" ></ tree:imgBox > </ mx:Application >