So i've been messing around with my game lately and hit a wall with this error:
[Fault] exception, information=ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
I know what it means but I'm totally lost what might be causing it :S
here is the code for child creation:
effect1 = new Effects1("smoke", 0, 0);
addChild(effect1);
effect1Array.push(effect1);
OR
effect1 = new Effects1("fire", 0, 4);
addChild(effect1);
effect1Array.push(effect1);
child removal:
for each(effect1 in effect1Array)
{
effect1.enterFrame();
if (effect1.die)
{
effect1Array.splice(effect1, 1);
removeChild(effect1);
}
}
now, Effects1.as:
blabla
public function Effects1(inType:String, inDir:int, inSpeed:int):void
{
type = inType;
my_dir = getRandom(361);
speed = inSpeed;
smokeFramesArray = new Array();
var row:int;
var col:int;
if (type == "smoke")
row = 0;
if (type == "fire")
row = 1;
for (var i:int = 0; i < 4; i++)
{
var frame:BitmapData = new BitmapData(wid,hei);
var frameRect:Rectangle = new Rectangle(i*wid,hei*row,wid,hei);
frame.copyPixels(smokeFireSPR, frameRect, frame.rect.topLeft);
smokeFramesArray.push(frame);
}
var random:int = getRandom(5)
bitmapData = smokeFramesArray[random];
}
public function enterFrame():void
{
if (!pause)
{
x+= speed*Math.cos(my_dir*(Math.PI/180));
y-= speed*Math.sin(my_dir*(Math.PI/180));
if (countdown > 0)
{
if ((countdown % 2) == 0)
alpha -= 0.1;
countdown -= 1;
}
else
die = true;
}
}
i dont have a slightest idea what might be the problem
