Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

error shows up after removing child

Explorer ,
Dec 03, 2015 Dec 03, 2015

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);

    }

   }

TOPICS
ActionScript
2.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 16, 2015 Dec 16, 2015

idk how it does change thats what trace tells me but i just dont know whats wrong with the code so idk

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 16, 2015 Dec 16, 2015
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 11, 2015 Dec 11, 2015

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));

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines