参考这篇文章 http://www.cnblogs.com/axes/p/3501424.html
[code]
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
/**
* ...
* @author amyflash.com
*/
public class Main extends Sprite
{
public function Main()
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private var all:Sprite = new Sprite();
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point
ok();
addChild(all);
}
private var tags:Array;
private var RADIUS:int = 200;
private var count:int = 20;
private var fallLength:int = 10; //焦距
private var centerx:int = 350;
private var centery:int = 350;
private var lines:Sprite = new Sprite();
private function ok():void{
tags = new Array();
lines.graphics.lineStyle(2,0x333333);
//lines.graphics.moveTo(centerx,centery);
for(var i:int=0;i<count;i++){
var a:Number , b:Number;
var k:Number = -1+(2*(i+1)-1)/count;
a = Math.acos(k);
b = a*Math.sqrt(count*Math.PI);
// var a = Math.random()*2*Math.PI;
// var b = Math.random()*2*Math.PI;
var x:Number = RADIUS * Math.sin(a) * Math.cos(b);
var y:Number = RADIUS * Math.sin(a) * Math.sin(b);
var z:Number = RADIUS * Math.cos(a);
var t:Ball = new Ball();
t.x = x;
t.y = y;
t.z = z;
tags.push(t);
all.addChild(t);
// t.move();
//lines.graphics.lineTo(t.x,t.y);
//lines.graphics.moveTo(t.x,t.y);
var scale:Number = fallLength/(fallLength-z);
var alpha:Number = (z+RADIUS)/(2*RADIUS);
//this.ele.style.fontSize = 15 * scale + "px";
//t.scaleX = 15 * scale;
//t.scaleY = 15 * scale;
//t.scaleZ = 15 * scale;
t.alpha =alpha+0.5;
}
all.x = centerx;
all.y = centery;
lines.x = all.x;
lines.y = all.y;
addChild(lines);
this.addEventListener(Event.ENTER_FRAME, doMove);
}
private function doMove(e:Event):void{
//trace(sd);
//lines.graphics.clear();
//lines.graphics.moveTo(centerx, centery);
//for(var i:int=0;i<count;i++){
//lines.graphics.lineTo(tags[i].x, tags[i].y);
//lines.graphics.moveTo(tags[i].x, tags[i].y);
//
//}
rotateX(this.mouseX*0.0001);
rotateY(this.mouseY*0.0001);
}
private function rotateX(angleX:Number):void{
var cos:Number = Math.cos(angleX);
var sin:Number = Math.sin(angleX);
for(var i:int=0;i<count;i++){
var y1:Number = tags[i].y * cos - tags[i].z * sin;
var z1:Number = tags[i].z * cos + tags[i].y * sin;
tags[i].y = y1;
tags[i].z = z1;
}
}
private function rotateY(angleY:Number):void{
var cos:Number = Math.cos(angleY);
var sin:Number = Math.sin(angleY);
for(var i:int=0;i<count;i++){
var x1:Number = tags[i].x * cos - tags[i].z * sin;
var z1:Number = tags[i].z * cos + tags[i].x * sin;
tags[i].x = x1;
tags[i].z = z1;
}
}
}
}
[/code]
[code]
package
{
import flash.display.Sprite;
import flash.filters.BitmapFilterQuality;
import flash.filters.BlurFilter;
import flash.filters.GlowFilter;
/**
* ...
* @author amyflash.com
*/
public class Ball extends Sprite
{
public function Ball()
{
super();
var ball:Sprite = new Sprite();
ball.graphics.beginFill(0xffffff*Math.random());
ball.graphics.drawCircle(0,0,8+3*Math.random());
//绘制;
ball.filters = [new BlurFilter(10, 10)];//添加模糊滤镜
addChild(ball);
}
}
}
[/code]