forked from: 3d_no4
ごめんなさいごめんなさい人のコード参考にというかパクリですね
// forked from Laqu's 3d_no4
//ごめんなさいごめんなさい人のコード参考にというかパクリですね
package
{
import flash.display.*;
import flash.events.*;
import flash.filters.*;
[SWF(backgroundColor="#000000")]
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 = 400;
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 - 3 * Math.cos(20 * radian)) * Math.cos(radian)*15;
var y:Number=(10 - 3 * Math.cos(20 * radian)) * Math.sin(radian)*15;
var z:Number=Math.sin(20 * radian)*60;
setCircle(x, y, z,Math.random()*2+5 );
}
}
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(getColor());
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.rotationZ +=(240-mouseX)/70;
}
private function getColor():int
{
var r:int = Math.random()*255;
var g:int = Math.random()*r;
var b:int = Math.random()*g;
return r<<16 | g<<16 | b;
}
}
}