3d_no2
package
{
import flash.display.*;
import flash.events.*;
import flash.filters.*;
public class Math3 extends Sprite
{
private var maxNum:uint = 500;
private var angle:Number = 0;
private var radian:Number = 0;
public function Math3()
{
init();
}
private function init():void
{
stage.frameRate=30;
stage.scaleMode=StageScaleMode.NO_SCALE;
stage.align=StageAlign.TOP_LEFT;
stage.quality=StageQuality.MEDIUM;
var radius:Number = 150;
var v:Number = 0;
var sw:Number = stage.stageWidth;
var sh:Number = stage.stageHeight;
for (var i:uint = 0; i < maxNum; i++)
{
v += 1;
radian = v * Math.PI / 180;
var x:Number=10 * Math.sin(5 * radian) * Math.cos(7 * radian) * 18;
var y:Number=10 * Math.sin(5 * radian) * Math.sin(7 * radian) * 18;
var z:Number=10 * Math.cos(5 * radian) * 18;
setCircle(x, y, z,Math.random()*2+2 );
}
}
private function setCircle(x:Number,y:Number,z:Number,radius:Number):void
{
var _x:Number = x;
var _y:Number = y;
var _z:Number = z;
var _radius:Number = radius;
var p:Sprite = new Sprite();
addChild(p);
p.addEventListener(Event.ENTER_FRAME,move3d);
var s:Sprite = new Sprite();
p.addChild(s);
p.x=p.y=240;
s.x=_x;
s.y=_y;
s.z=_z;
s.rotationY=rotationY;
var sp:Sprite=new Sprite();
sp.graphics.beginFill(Math.random()*0xFFFFFF);
sp.graphics.drawCircle(0,0,_radius);
s.addChild(sp);
sp.alpha=Math.random();
sp.blendMode=BlendMode.MULTIPLY;
sp.addEventListener(Event.ENTER_FRAME,enterFrame);
}
private function enterFrame(e:Event):void
{
e.target.x = Math.cos(angle) * 2;
e.target.y = Math.sin(angle) * 2;
angle += 5;
}
private function move3d(e:Event):void
{
e.target.rotationX +=(240-mouseY)/70;
e.target.rotationY +=(240-mouseX)/70;
}
}
}