• 使用效果使用ActionScript触发效果


    <?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"
                   applicationComplete="init()">
      <s:layout>
        <s:VerticalLayout paddingLeft="20" paddingTop="20" />
      </s:layout>
      <fx:Script>
        <![CDATA[
          import flash.utils.Timer;
         
          import spark.effects.animation.RepeatBehavior;
         
          [Bindable]
          protected var secondsTillDue:int = 5;
          protected var _timer:Timer;
         
          protected function init():void{
            _timer = new Timer(1000); //tick every 1000ms  设置每1000ms运行一次的计时器
            _timer.addEventListener('timer', onTimerTick);
            _timer.start();
          }
         
          protected function onTimerTick(event:TimerEvent):void{
            secondsTillDue = Math.max(secondsTillDue-1, 0);//更新secondsTillDue的值
            if(secondsTillDue == 0){//如果secondsTillDue为0,那么播放效果并停止计时器
              effect.play();
              _timer.stop();
            }
          }
        ]]>
      </fx:Script>
      <fx:Declarations>
        <s:GlowFilter id="filter" color="#de7800" blurX="20" blurY="20" />//设置GlowFilter来发出橘黄色的光
        <s:AnimateFilter id="effect" target="{box}" bitmapFilter="{filter}"//AnimateFilter来播放效果
                         duration="1000" repeatCount="0"
                         repeatBehavior="{RepeatBehavior.REVERSE}">
          <s:SimpleMotionPath property="alpha" valueFrom="0" valueTo="1" />//设置动画路径来创建alpha动画( RepeatBehavior常量REVERSE,LOOP创建往复效果)
        </s:AnimateFilter>
      </fx:Declarations>
      <s:Label id="labelField" fontWeight="bold" fontSize="14"
               text="Due in {secondsTillDue} seconds" />
      <s:Rect id="box" width="200" height="200">
        <s:fill>
          <s:SolidColor color="black" />
        </s:fill>
      </s:Rect>
    </s:Application>

  • 相关阅读:
    jquery mobile
    可能用到的负边距应用
    兼容性问题
    less和scss
    函数的继承
    关于canvas
    html5表单属性
    html代码
    git 拉取远程分支 --本地分支不存在
    git 删除分支
  • 原文地址:https://www.cnblogs.com/tsg0723/p/2642422.html
Copyright © 2020-2023  润新知