Datasheet

Chapter 1: Understanding Flash3D
19
var myAngle:Number =0;//Angle of ball
//Add Multiple Particles
function updateStage():void
{
//Draw a Ball
var ball:Sprite = new Sprite
//Assign a random ball color
ball.graphics.beginFill(Math.random()*0xffffff);
//draws your ball at 0,0
ball.graphics.drawCircle(0, 0, ballRadius);
ball.graphics.endFill();//ends the fill
//Add ball to the stage
addChild(ball);
//Push the ball into a particle array
particles_ary.push(ball);
}
//Place Particles on the Stage
for(var i:uint = 0; i < numOfParticles; i++)
{
updateStage();
numVar++;
//Start Looping
if(numVar==numOfParticles){
addEventListener(Event.ENTER_FRAME, myonEnterFrame);}
}
//Looping function
function myonEnterFrame(event:Event):void{
myAngle=myAngle-.1;//iterates angle
for(var i:uint = 0; i < particles_ary.length; i++)
{
//ball parametric orbit x
var newAngle:Number=myAngle+i/20;
particles_ary[i].alpha=1/(i+1)+.2;
particles_ary[i].x =
(100+60*Math.cos(2*newAngle))*Math.cos(newAngle/4)+CenterX;
//ball parametric orbit y
particles_ary[i].y =
(100+60*Math.cos(2*newAngle))*Math.sin(newAngle/4)+CenterY;
//ball parametric orbit z
particles_ary[i].z = 60*Math.sin(2*newAngle);
}}
No discussion about particles would be complete without mention of Seb Lee Delisle, an expert in
particle systems and one of the Papervision3D team members. Seb has a great site that covers particle
creation in Papervision3D at http://www.sebleedelisle.com/. Next on the list of particle super stars is the
c01.indd 19c01.indd 19 12/14/09 3:03:29 PM12/14/09 3:03:29 PM