Rotating particles.
Hi. This is the first time i have ever used Actionscript and I am having a problem which i am sure will prove trivial to you and not take up much of your time. I have created an animation which sends "particles" flying out from a central point. This all works fine. I now wan't to get them to rotate and cannot seem to get it to work. Here is my current code. Very grareful for any help:
var particleArray:Array = new Array();
var maxParticles:Number = 100;
function addparticle(e:Event)
{
var p1:particle = new particle();
var p2:particle2 = new particle2();
var p3:particle3 = new particle3();
var p4:particle4 = new particle4();
var p5:particle5 = new particle5();
p1.x = stage.stageWidth/2;
p1.y = stage.stageHeight/2;
p2.x = stage.stageWidth/2;
p2.y = stage.stageHeight/2;
p3.x = stage.stageWidth/2;
p3.y = stage.stageHeight/2;
p4.x = stage.stageWidth/2;
p4.y = stage.stageHeight/2;
p5.x = stage.stageWidth/2;
p5.y = stage.stageHeight/2;
p1.alpha = Math.random() * .8 + .2;
p1.scaleX = p1.scaleY = Math.random() * .8 + .2;
p2.alpha = Math.random() * .8 + .2;
p2.scaleX = p2.scaleY = Math.random() * .8 + .2;
p3.alpha = Math.random() * .8 + .2;
p3.scaleX = p3.scaleY = Math.random() * .8 + .2;
p4.alpha = Math.random() * .8 + .2;
p4.scaleX = p4.scaleY = Math.random() * .8 + .2;
p5.alpha = Math.random() * .8 + .2;
p5.scaleX = p5.scaleY = Math.random() * .8 + .2;
p1.xMovement = Math.random() * 10 - 5;
p1.yMovement = Math.random() * 10 - 5;
p2.xMovement = Math.random() * 10 - 5;
p2.yMovement = Math.random() * 10 - 5;
p3.xMovement = Math.random() * 10 - 5;
p3.yMovement = Math.random() * 10 - 5;
p4.xMovement = Math.random() * 10 - 5;
p4.yMovement = Math.random() * 10 - 5;
p5.xMovement = Math.random() * 10 - 5;
p5.yMovement = Math.random() * 10 - 5;
particleArray.push(p1);
particleArray.push(p2);
particleArray.push(p3);
particleArray.push(p4);
particleArray.push(p5);
addChild(p1);
addChild(p2);
addChild(p3);
addChild(p4);
addChild(p5);
p1.cacheAsBitmap = true ;
p2.cacheAsBitmap = true ;
if (particleArray.length>= maxParticles)
{
removeChild(particleArray.shift());
}
p1.addEventListener(Event.ENTER_FRAME,moveparticle);
p2.addEventListener(Event.ENTER_FRAME,moveparticle);
p3.addEventListener(Event.ENTER_FRAME,moveparticle);
p4.addEventListener(Event.ENTER_FRAME,moveparticle);
p5.addEventListener(Event.ENTER_FRAME,moveparticle);
}
function moveparticle(e:Event)
{
e.currentTarget.x += e.currentTarget.xMovement;
e.currentTarget.y += e.currentTarget.yMovement;
}
var myTimer:Timer = new Timer(200);
myTimer.addEventListener(TimerEvent.TIMER, addparticle);
myTimer.start();