I am a newbee and just starting to learn about AS3. Copied some ideas and tried to paint a single particle on the stage for starters. No success! I get this…
[COLOR=Red]1061: Call to a possibly undefined method addChild through a reference with static type flash.display:DisplayObject.[/COLOR]
In an “Particle.as” file I have this code…
**[COLOR=Blue]package
{
import flash.display.*;
public class Particle extends MovieClip
{
public function Particle ( spriteclass : Class, targetclip : DisplayObject, xpos : Number, ypos : Number)
{
// instantiate a new particle graphic
if(spriteclass) {
clip = new spriteclass();
// and add it to the stage
targetclip.addChild(clip);
// and set its position
clip.x = xpos;
clip.y = ypos;
}
public function setVel(xvel:Number,yvel:Number)
{
xVel = xvel;
yVel = yvel;
}
public function update()
{
clip.x = xVel;
clip.y = yVel;
}
public function destroy():void
{
clip.parent.removeChild(clip);
}
}
}[/COLOR]**
Also, on the stage layer 1 frame 1 I have this code…
[COLOR=Indigo]**var particle = new Particle(spark, this, 275,200);
**[/COLOR]
What is wrong here? And keep in mind that I am a just starting up with AS3…
TIA
DKean