3d_no1
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.LOW;
var radius:Number = 200;
var v:Number = 0;
var sw:Number = stage.stageWidth;
var sh:Number = stage.stageHeight;
for (var i:uint = 0; i < maxNum; i++)
{
v += 2;
radian = v * Math.PI / 180;
var x:Number=(8 + 3 * Math.cos(5 * radian)) * Math.cos(2 * radian)*20;
var y:Number=(8 + 3 * Math.cos(5 * radian)) * Math.sin(2 * radian)*20;
var z:Number=Math.sin(5 * radian) * 100;
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;
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) * 5;
e.target.y = Math.sin(angle) * 5;
angle += 5;
}
private function move3d(e:Event):void
{
e.target.rotationX +=(240-mouseY)/70;
e.target.rotationY +=(240-mouseX)/70;
}
}
}