forked from: flash on 2009-2-5
...
@author Sergey Gonchar
package
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.filters.BlurFilter;
import flash.filters.ColorMatrixFilter;
import flash.geom.Point;
/**
* ...
* @author Sergey Gonchar
*/
[SWF(width=800, height=600, backgroundColor=0xffffff, frameRate=24)]
public class FlashTest extends Sprite
{
public function FlashTest()
{
this.addEventListener(Event.ADDED_TO_STAGE, _init);
}
private function _init(e:Event):void
{
this.removeEventListener(Event.ADDED_TO_STAGE, _init);
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
var bmd:BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight);
addChild(new Bitmap(bmd));
var cont:Sprite = new Sprite();
addChild(cont);
cont.x=stage.stageWidth/2;
cont.y=stage.stageHeight/2;
for (var i:int = 1; i < 5; i++)
for (var j:int = 1; j < 5; j++)
for (var ij:int = 1; ij < 5; ij++)
{
var obj:Sprite=new Sprite();
obj.x=250 *(i/5 - .5);
obj.y=250 * (j / 5 - .5);
obj.z=250 * (ij / 5 - .5);
obj.graphics.beginFill(0x444444,1);
obj.graphics.drawCircle(0, 0, 5);
cont.addChild(obj);
}
addEventListener(Event.ENTER_FRAME, function loop(e:Event):void{
for(var h:int=0; h<cont.numChildren; h++)
{
var rz1:Number = (cont.getChildAt(h).y*Math.sin(cont.mouseY/20 * (Math.PI/180)) + cont.getChildAt(h).z*Math.cos(cont.mouseY/20 * (Math.PI/180)));
cont.getChildAt(h).y = Number(cont.getChildAt(h).y*Math.cos(cont.mouseY/20 * (Math.PI/180)) - cont.getChildAt(h).z*Math.sin(cont.mouseY/20 * (Math.PI/180)));
cont.getChildAt(h).z = Number(-cont.getChildAt(h).x*Math.sin(cont.mouseX/20 * (Math.PI/180)) + rz1*Math.cos(cont.mouseX/20 * (Math.PI/180)));
cont.getChildAt(h).x = Number(cont.getChildAt(h).x*Math.cos(cont.mouseX/20 * (Math.PI/180))+rz1*Math.sin(cont.mouseX/20 * (Math.PI/180)));
cont.getChildAt(h).scaleX = 300 / (cont.getChildAt(h).z+250);
cont.getChildAt(h).scaleY = 300 / (cont.getChildAt(h).z+250);
}
bmd.draw(cont.parent);
bmd.applyFilter(bmd, bmd.rect, new Point(0, 0), new BlurFilter());
bmd.applyFilter(bmd, bmd.rect, new Point(0, 0), new ColorMatrixFilter([ 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0]));
bmd.scroll(10,0);
});
}
}
}