-- welcome to wonderfl --
wonderfl is a service where you can build a Flash online.
write Actionscript3 code in a textarea,
and your code will be compiled server side.
Your compiled Flash will be reloaded automatically
in the right side of the page,
so write code and see it real-time.
Well, why not "FORK" this code and see how it goes?
// forked from pipeep's MotionRotationTest
// forked from CrunchyMcDugals's forked from: wonderfl KeyVisual V.4.en
// forked from mash's wonderfl KeyVisual V.4.en
//
// -- welcome to wonderfl --
//
// wonderfl is a service where you can build a Flash online.
//
// write Actionscript3 code in a textarea,
// and your code will be compiled server side.
//
// Your compiled Flash will be reloaded automatically
// in the right side of the page,
// so write code and see it real-time.
//
// Well, why not "FORK" this code and see how it goes?
//
package {
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.MovieClip;
import flash.display.Shape;
import flash.text.TextField;
import flash.filters.DropShadowFilter;
import flash.filters.BlurFilter;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.geom.Rectangle;
import flash.geom.ColorTransform;
import flash.geom.Point;
import flash.utils.Timer;
import flash.events.TimerEvent;
[SWF(backgroundColor="#FFFFFF", frameRate=10)]
public class Simple3D extends Sprite {
private var square:Shape;
private var motionBlur:Bitmap;
private var debug:TextField;
private var updateTimer:Timer;
public function Simple3D() {
square = new Shape();
square.graphics.beginFill(0xFF666666);
square.graphics.drawRect(0, 0, 30, 30);
addChild(square);
square.rotation = 45;
square.x = stage.stageWidth/2.;
square.y = stage.stageHeight/2.;
updateTimer = new Timer(20);
updateTimer.addEventListener(TimerEvent.TIMER, rotater);
updateTimer.start();
filters = new Array(new DropShadowFilter());
motionBlur = new Bitmap(new BitmapData(stage.stageWidth, stage.stageHeight));
parent.addChildAt(motionBlur, 0);
stage.addEventListener(MouseEvent.MOUSE_MOVE, handleMouseMove);
debug = new TextField();
debug.width = stage.stageWidth;
parent.addChild(debug);
debug.text = "initialized";
}
private function rotater(event:Event):void {
debug.text = "rotating";
square.rotationY += 10*2;
square.rotationZ += 7*2;
square.rotationX += 5*2;
renderMotionBlur();
}
private function renderMotionBlur():void { //i've always wanted to do a motionblur
debug.text = "renderingBlur";
motionBlur.bitmapData.draw(this);
var cTransform:ColorTransform = new ColorTransform();
cTransform.alphaMultiplier = 0.99;
motionBlur.bitmapData.colorTransform(motionBlur.bitmapData.rect, cTransform);
motionBlur.bitmapData.applyFilter(motionBlur.bitmapData, motionBlur.bitmapData.rect, new Point(), new BlurFilter(3, 3));
//parent.addChildAt(motionBlur, 0); //stay on bottom
}
private function handleMouseMove(event:MouseEvent):void {
debug.text = "runMouse";
square.x = event.localX;
square.y = event.localY;
}
}
}