自定义触发器(在自定义动画效果的基础上)

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

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

组件: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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值