flash on 2009-2-4
package {
import flash.display.Sprite;
import flash.text.TextField;
import flash.utils.Timer;
import flash.events.*;
[SWF(backgroundColor="#000000", frameRate=60)]
public class FlashTest extends Sprite {
private var textf:TextField;
private var count:Number = 255;
private var updown:Number = 0;
private var ox:Number = 0;
private var oy:Number = 0;
public function FlashTest() {
// write as3 code here..
init();
}
public function init():void {
textf = new TextField();
textf.x += 10;
textf.y += 10;
textf.width = 465;
textf.height = 20;
addChild(textf);
//addEventListener(Event.ENTER_FRAME,mouseMoveHandler);
var myTimer:Timer = new Timer(1,0);
myTimer.addEventListener(TimerEvent.TIMER, mouseMoveHandler);
myTimer.start();
}
private function mouseMoveHandler(e:Event):void {
if(updown == 0){
count+=256;
}else if(updown == 1){
count-=1;
}else if(updown == 2){
count+=65536;
}else if(updown == 3){
count-=256;
}else if(updown == 4){
count+=1;
}else if(updown == 5){
count-=65536;
}
if(count == 65535){
updown = 1;
}else if(count == 65280){
updown = 2;
}else if(count == 16776960){
updown = 3;
}else if(count == 16711680){
updown = 4;
}else if(count == 16711935){
updown = 5;
}else if(count == 255){
updown = 0;
}
textf.htmlText = "<font color='#ffffff'>"+String(count)+"</font>";
var circle:blurCircle = new blurCircle(stage.mouseX,stage.mouseY,ox,oy,count);
addChild(circle);
ox = stage.mouseX;
oy = stage.mouseY;
}
}
}
import flash.display.Sprite;
import flash.filters.BlurFilter;
import flash.filters.BitmapFilterQuality;
import caurina.transitions.Tweener;
import caurina.transitions.properties.FilterShortcuts;
class blurCircle extends Sprite {
private var circle:Sprite;
public function blurCircle(nx:Number,ny:Number,ox:Number,oy:Number,col:Number) {
// write as3 code here..
init(nx,ny,ox,oy,col);
}
private function init(dx:Number,dy:Number,odx:Number,ody:Number,dcol:Number):void {
FilterShortcuts.init();
var rangeX:Number = Math.abs(odx-dx);
var rangeY:Number = Math.abs(ody-dy);
var ranges:Number = Math.pow(rangeX,2)+Math.pow(rangeY,2);
var range:Number = Math.ceil(Math.pow(ranges,0.5));
circle = new Sprite();
circle.graphics.beginFill(dcol);
circle.graphics.drawCircle(0,0, range);
circle.x = dx;
circle.y = dy;
var blur:BlurFilter = new BlurFilter();
blur.blurX = rangeX/2;
blur.blurY = rangeY/2;
blur.quality = BitmapFilterQuality.HIGH;
circle.filters = [blur];
Tweener.addTween(circle, { transition:"easeOutQuart", _Blur_blurX:rangeX/4, _Blur_blurY:rangeY/4, alpha:0, scaleX:0.1, scaleY:0.1, time:0.7, onComplete:removeCircle } );
//x:dx-(odx-dx), y:dy-(ody-dy)
addChild(circle);
}
private function removeCircle():void {
removeChild(circle);
}
}