关闭

flash加载动画效果AS3.0代码实现

2393人阅读 评论(0) 收藏 举报
分类:
package
{
import flash.display.Shape;
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.Matrix;
import flash.utils.Timer;
import flash.events.TimerEvent;

public class loading extends Sprite
{
private var nums:int = 12;
private var m2:Matrix = new Matrix();
private var m:Matrix = new Matrix();
private var Abar:Array = new Array();
private var segAngle:Number;
private var seg:Number;
private var j:Number = 0;
private var timer:Timer = new Timer(50);
public function loading():void
{
initBar();
}

private function initBar():void
{
segAngle = 2 * Math.PI / this.nums;
seg = 1 / this.nums;
for (var i:int = 0; i < this.nums ; i++)
{
var bar:Shape=new Shape();
Abar[i] = bar;
bar.graphics.beginFill(0xffffff);
bar.graphics.drawRoundRect(0,0,10,3,4,4);
bar.graphics.endFill();
this.addChild(bar);
bar.x = bar.y = 100;
m.identity();
m.translate(7,-1);
m.rotate(segAngle*i);
m.translate(-7,1);
m2.identity();
m2.translate(100,100);
m.concat(m2);
bar.transform.matrix = m;
}
timer.addEventListener(TimerEvent.TIMER,alphaHalder);
timer.start();
}

private function alphaHalder(evt:TimerEvent):void
{
for (var i:int = 0; i < this.nums; i++)
{
var bar:Shape = Abar[i] as Shape;
bar.alpha = j;
if (j == 1.0833333333333333)
{
j = 0;
}
j += seg;
}
}
}
}
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:330671次
    • 积分:3779
    • 等级:
    • 排名:第8478名
    • 原创:22篇
    • 转载:178篇
    • 译文:3篇
    • 评论:58条
    最新评论