/* * Class that represents a particle in a particle system */ class util.Particle { private var xPos:Number; private var yPos:Number; private var speed:Number; private var targetMC:MovieClip; private var particleMC:MovieClip; /* * CONSTRUCTOR * @x: the x position of this particle * @y: the y position of this particle * @symbol: the graphical representation of this particle * @target: the movieclip where this particle should be rendered */ public function Particle(x:Number, y:Number, velocity:Number, symbol:String, target:MovieClip) { var d = target.getNextHighestDepth(); targetMC = target; particleMC = targetMC.attachMovie(symbol, symbol+"_"+velocity, d); setXPos(x); setYPos(y); setSpeed(velocity); } /* * Removes this particle from stage */ public function remove() { particleMC.unloadMovie(); } /* * Sets the x postion of this particle * @x: the new x position */ public function setXPos(x:Number):Boolean{ if(!isNaN(x)){ this.xPos = x; particleMC._x = xPos; return true; } return false; } /* * Returns the x position of this particle */ public function getXPos():Number{ return xPos; } /* * Sets the y postion of this particle * @x: the new y position */ public function setYPos(y:Number):Boolean{ if(!isNaN(y)){ this.yPos = y; particleMC._y = yPos; return true; } return false; } /* * Returns the y position of this particle */ public function getYPos():Number{ return yPos; } /* * Sets the speed of this particle * @s: the new speed */ public function setSpeed(s:Number):Boolean{ if(!isNaN(s)){ this.speed = s; return true; } return false; } /* * Returns the speed of this particle */ public function getSpeed():Number{ return speed; } /* * Sets the graphical representation of this particle * @mc: the movieclip that is the graphical representation of this particle public function setParticleMC(mc:MovieClip):Void { particleMC = mc; }*/ /* * Returns the reference to the graphical representation of this particle */ public function getParticleMC():MovieClip { return particleMC; } }