Copy link to clipboard
Copied
so when evil dies it plays a death animation and is removed on the last frame
it works fine but an error show up
The supplied DisplayObject must be a child of the caller.
if(evil.currentFrame == 47)
{
if(contains(evil))
{
removeChild(evil);
}
if(contains(evilShadow))
{
removeChild(evilShadow);
}
}
Copy link to clipboard
Copied
idk how it does change thats what trace tells me but i just dont know whats wrong with the code so idk
Copy link to clipboard
Copied
you can use the link in message 22 to solve the problem yourself.
but if it's too time-consuming for you and you want to hire me, send me a private message.
Copy link to clipboard
Copied
evilShadow's depth will not change from that code. you can confirm using the trace statement:
trace('before',evilShadow.parent.getChildIndex(evilShadow)); if(evilHealth <= 0)
{
evilDies = true;
}
if(evil.currentFrame == 47)
{
var randomNum:Number = Math.random()*7
var roundedNum:Number = Math.floor(randomNum);
if(roundedNum == 0)
{
evilShadow.x = char.x+3000;
evilShadow.y = char.y+3000;
}
if(roundedNum == 1)
{
evilShadow.x = char.x+2000;
evilShadow.y = char.y;
}
if(roundedNum == 2)
{
evilShadow.x = char.x+3000;
evilShadow.y = char.y-3000;
}
if(roundedNum == 3)
{
evilShadow.x = char.x
evilShadow.y = char.y-2000;
}
if(roundedNum == 4)
{
evilShadow.x = char.x-3000;
evilShadow.y = char.y+3000;
}
if(roundedNum == 5)
{
evilShadow.x = char.x-3000;
evilShadow.y = char.y-3000;
}
if(roundedNum == 6)
{
evilShadow.x = char.x-2000;
evilShadow.y = char.y;
}
if(roundedNum == 7)
{
evilShadow.x = char.x;
evilShadow.y = char.y+2000;
}
evilHealth = 200;
evilDies = false;
died = false;
fadePresent = false;
darkhere = false;
trace('after',evilShadow.parent.getChildIndex(evilShadow));
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more