[ActionScript 3.0] AS3实现图像径向转旋效果

原图    [ActionScript 3.0] AS3实现图像径向转旋效果

效果     [ActionScript 3.0] AS3实现图像径向转旋效果

import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.BlendMode;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.filters.BlurFilter;
import flash.geom.ColorTransform;
import flash.geom.Matrix;
import flash.geom.Point;
import flash.text.TextField; var bmd:BitmapData;
var screen:Bitmap;
var scale:Number;
var r:Number; bmd = new 位图1();
screen = new Bitmap(bmd.clone());
addChild(screen); scale = 1.0;
r = 0.0; stage.addEventListener(MouseEvent.CLICK,onClick);
function onClick(event:MouseEvent):void
{
if (hasEventListener(Event.ENTER_FRAME)) {
removeEventListener(Event.ENTER_FRAME,onEnterFrame);
scale = 1.0;
r = 0.0;
screen.bitmapData = bmd.clone();
} else {
addEventListener(Event.ENTER_FRAME,onEnterFrame);
}
} function onEnterFrame(event:Event):void
{
r += 0.05;
scale *= 1.05;
var m:Matrix = new Matrix();
m.translate(-bmd.width / 2,-bmd.height / 2);
m.scale(scale,scale);
m.rotate(r);
m.translate(bmd.width / 2,bmd.height / 2);
screen.bitmapData.draw(bmd,m,new ColorTransform(1,1,1,0.2),BlendMode.ADD);
}
上一篇:某集团BI决策系统建设方案分享


下一篇:换一个思路压缩图片,RGB转YUV