组件: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>
本文介绍了一个使用 Flash 和 Flex 构建的图片组件 imgBox,该组件通过自定义事件来控制图片显示与隐藏,并利用 NewIrisEffect 实现了图片的渐显渐隐效果。文章展示了如何通过简单的鼠标操作触发复杂的视觉变化。
5646

被折叠的 条评论
为什么被折叠?



