[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);
}

 

posted on 2015-11-09 17:52  晏过留痕  阅读(539)  评论(0编辑  收藏  举报