加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

flex_对象动画;

发布时间:2020-12-15 04:57:09 所属栏目:百科 来源:网络整理
导读:=animationApp.mxml ?xml version="1.0" encoding="utf-8"? s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" ? xmlns:s="library://ns.adobe.com/flex/spark" ? xmlns:mx="library://ns.adobe.com/flex/mx" ? xmlns:aspackage="aspackage.*" ? minW

=>animationApp.mxml

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
? xmlns:s="library://ns.adobe.com/flex/spark"
? xmlns:mx="library://ns.adobe.com/flex/mx"
? xmlns:aspackage="aspackage.*"
? minWidth="955" minHeight="600" pageTitle="TheStudioOfCenyebao">
<s:layout>
<s:VerticalLayout horizontalAlign="center" verticalAlign="middle"/>
</s:layout>

<fx:Script>
<![CDATA[

]]>
</fx:Script>


<fx:Declarations>
<!-- 非可视元素 ?-->
</fx:Declarations>


<s:VGroup width="320" height="230" horizontalAlign="center" verticalAlign="middle">
<aspackage:MyComponent id="myComponent"/>
</s:VGroup>
</s:Application>


=>MyComponent.as

package aspackage { import flash.display.Sprite; import flash.events.Event; import flash.events.MouseEvent; import flash.events.TimerEvent; import flash.utils.Timer; import mx.core.UIComponent; public class MyComponent extends UIComponent { /** * 属性*/ /*圆*/ private var circle:Sprite; /*计时器*/ private var myTimer:Timer; /*是否已经单击*/ private var hasClick:Boolean=false; /** * 构造函数 */ public function MyComponent() { /** * 绘制圆*/ circle=new Sprite(); circle.graphics.beginFill(0x990000); circle.graphics.drawCircle(50,50,50); circle.graphics.endFill(); circle.useHandCursor=true; circle.buttonMode=true; this.addChild(circle); /*圆_侦听单击事件*/ circle.addEventListener(MouseEvent.CLICK,startAnimationFn); /*初始化计时器*/ myTimer=new Timer(2000,1); myTimer.addEventListener(TimerEvent.TIMER_COMPLETE,onTimerCompleteHandler); } /** * 计时函数 * @param event */ private function onTimerCompleteHandler(event:TimerEvent):void { /** * 再一次*/ circle.alpha=1; hasClick=false; } /** * 产生动画效果_圆逐渐模糊; * @param event */ private function startAnimationFn(event:MouseEvent):void { if (myTimer.running) { myTimer.reset(); } myTimer.start(); if (!hasClick) { circle.addEventListener(Event.ENTER_FRAME,fadeCircleFn); hasClick=true; } } /** * 圆逐渐模糊 * @param event * About_When this animation starts,this function is called every frame(每帧). * The change made by this function (updated to the screen every frame) is what causes the animation to occur. */ private function fadeCircleFn(event:Event):void { /*通过改变圆的alpha值,来进行逐渐模糊效果*/ circle.alpha-=.05; if (circle.alpha <= 0) { circle.removeEventListener(Event.ENTER_FRAME,fadeCircleFn); } } } }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读