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

Error #2025

Participant ,
Apr 12, 2012 Apr 12, 2012

Copy link to clipboard

Copied

hi .. how are you guysuld

iam making a game  and its all good except the last thing

if i wanna finish the game the dragon and health bar and fire should stop attacking and should removing

here this is the code

the problem from the red lines only

package

{

    import flash.display.MovieClip;

    import flash.events.KeyboardEvent;

    import flash.ui.Keyboard;

    import flash.events.Event;

    import flash.events.MouseEvent;

public class game extends MovieClip {

  

public  var firetalent:uint;

    public var vx:int;

  public var points:uint

 

  public function game (){

        run();

       

        removeChild(b1)

        removeChild(b2)

        removeChild(c1)

        removeChild(c2)

        removeChild(d1)

        removeChild(d2)

        removeChild(e1)

        removeChild(e2)

        dragon.gotoAndStop(1)

        NUMBERS.visible = false;

        NUMBERS.stop();

        zelda.stop()

        a1.visible = false

            a2.visible = false

        fire.visible = false

        b1.visible = false

            b2.visible = false

           

            c1.visible = false

            c2.visible = false

           

            d1.visible = false

            d2.visible = false

           

            e1.visible = false

            e2.visible = false

           

           

            a1.addEventListener(MouseEvent.CLICK, onmouseclicka1);

            a2.addEventListener(MouseEvent.CLICK, onmouseclicka2);

           

            b1.addEventListener(MouseEvent.CLICK, onmouseclickb1);

            b2.addEventListener(MouseEvent.CLICK, onmouseclickb2);

           

            c1.addEventListener(MouseEvent.CLICK, onmouseclickc1);

                c2.addEventListener(MouseEvent.CLICK, onmouseclickc2);

             

                d1.addEventListener(MouseEvent.CLICK, onmouseclickd1);

                d2.addEventListener(MouseEvent.CLICK, onmouseclickd2);

               

                e1.addEventListener(MouseEvent.CLICK, onmouseclicke1);

                e2.addEventListener(MouseEvent.CLICK, onmouseclicke2);

               

           

           

        hero.gotoAndStop(3);

      

    }

  

    public function run(){

      

        addEventListener(Event.ENTER_FRAME, onEnterFrame);

        stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);

        stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);

       

spell1.addEventListener(MouseEvent.CLICK,onspell)

    firstaid.addEventListener(MouseEvent.CLICK,firstaid1)  

    }

  

  

        function onEnterFrame(event:Event):void

        {

           

            if(dragonhealthbar.width == 0 ){

            stage.removeChild(fire)

            stage.removeChild(dragonhealthbar)

            stage.removeChild(dragon)

           

       

        }

           

            if(monster.hitTestObject(wall))

              {

                  dragonhealthbar.width -=3

                  dragon.gotoAndStop(2);

                 

              }

            if(!monster.hitTestObject(wall))

              {

                 dragon.gotoAndStop(1)

               

              }

           

           

            if(firetalent >= 1){

           

           

            monster.visible = true;

            monster.x -= 10;

            monster.y += 10;

           

            if(monster.y >=400){

        monster.x = 247

        monster.y =0;

        firetalent--

        monster.visible = false;

       

            }

            }

           

        if(points >= 2){

        spell1.alpha = 1;

        spell1.enabled = true;

        }

        else

        {

            spell1.alpha = .3;

            spell1.enabled = false;

        }

       

       

        if(points >= 3){

        firstaid.alpha = 1;

        firstaid.enabled = true;

        }

        else

        {

            firstaid.alpha = .3;

            firstaid.enabled = false;

        }

           

            score.text = String(points);

   

   

    if (score.text < "0" ){

score.text = "0";}

if(healthbar.width >80){

zelda.gotoAndStop(1)

}

if(healthbar.width >60 &&healthbar.width <80 ){

zelda.gotoAndStop(2)

}

if(healthbar.width >40 &&healthbar.width <60 ){

zelda.gotoAndStop(3)

}

if(healthbar.width >20 &&healthbar.width <40 ){

zelda.gotoAndStop(4)

}

if(healthbar.width >0 &&healthbar.width <20 ){

zelda.gotoAndStop(5)

}

if(dragon.hitTestObject(hero)){

     stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);

   

    NUMBERS.visible = true;

    a1.visible = true;

            a2.visible = true;

        fire.visible = true

fire.x += 20

fire.y +=18

fire.width +=3

fire.height +=3

if(fire.y >= 400){

    fire.width = 31;

    fire.height = 29

    fire.x = 94

    fire.y =239}

   

   

   

    if(hero.hitTestObject(fire)){

           hero.gotoAndStop(5);

           healthbar.width -= .5;

         

           }

           if(!hero.hitTestObject(fire)){

           hero.gotoAndStop(3);

         

           }

         }

}

   

           public function onmouseclicka1 (event:MouseEvent):void{

             points++

             removeChild(a1)

               removeChild(a2)

               addChild(b1)

                addChild(b2)

               b1.visible = true

                b2.visible = true

                NUMBERS.gotoAndStop(2)

              

              

           }

      

           public function onmouseclicka2 (event:MouseEvent):void{

               points +=2;

                addChild(b1)

                addChild(b2)

                removeChild(a1)

                removeChild(a2)

                 b1.visible = true

                b2.visible = true

                NUMBERS.gotoAndStop(2)

              

           }

           public function onmouseclickb1 (event:MouseEvent):void{

               points ++;

               addChild(c1)

                addChild(c2)

               removeChild(b1)

                removeChild(b2)

                 c1.visible = true

                c2.visible = true

                NUMBERS.gotoAndStop(3)

           }

          

           public function onmouseclickb2 (event:MouseEvent):void{

               

                removeChild(b1)

                removeChild(b2)

                addChild(c1)

                addChild(c2)

                c1.visible = true

                c2.visible = true

                NUMBERS.gotoAndStop(3)

                points +=2;

           }

          

          

           public function onmouseclickc1 (event:MouseEvent):void{

               points +=1;

               addChild(d1)

                addChild(d2)

               removeChild(c1)

              

                removeChild(c2)

                 d1.visible = true

                d2.visible = true

                NUMBERS.gotoAndStop(4)

           }

          

           public function onmouseclickc2 (event:MouseEvent):void{

              points +=2;

              addChild(d1)

                addChild(d2)

              removeChild(c1)

                removeChild(c2)

                 d1.visible = true

                d2.visible = true

                NUMBERS.gotoAndStop(4)

           }

          

           public function onmouseclickd1 (event:MouseEvent):void{

                points +=1

               addChild(e1)

                addChild(e2)

               removeChild(d1)

                removeChild(d2)

                 e1.visible = true

                e2.visible = true

                NUMBERS.gotoAndStop(5)

           }

          

           public function onmouseclickd2 (event:MouseEvent):void{

               points +=2;

                addChild(e1)

                addChild(e2)

                removeChild(d1)

                removeChild(d2)

                 e1.visible = true

                e2.visible = true

                NUMBERS.gotoAndStop(5)

               

           }

           public function onmouseclicke1 (event:MouseEvent):void{

               points +=1;

               removeChild(e1)

                removeChild(e2)

                removeChild(NUMBERS)      

                }

          

           public function onmouseclicke2 (event:MouseEvent):void{

               points +=2;

                               removeChild(NUMBERS)      

               removeChild(e1)

                removeChild(e2)

           }

          

          

          

  

public function onKeyDown(event:KeyboardEvent):void{

if (event.keyCode == Keyboard.LEFT){

hero.gotoAndStop(1);

hero.x -=3

}

if (event.keyCode == Keyboard.RIGHT){

hero.gotoAndStop(2);

hero.x +=3

}

}

public function onKeyUp (event:KeyboardEvent):void{

  

if(event.keyCode == Keyboard.LEFT){

    hero.gotoAndStop(3)

}

else if (event.keyCode == Keyboard.RIGHT){

    hero.gotoAndStop(4)

}

}

public function onspell (event:MouseEvent):void {

    if(points >=2){

    firetalent +=1

    points -=2

    }

   

}

public function firstaid1 (event:MouseEvent):void {

    if(points >=3){

   

    healthbar.width +=90

    if(healthbar.width >=90){

    healthbar.width =90

    }

    points -= 3;

    }

}

}

}

here the full eror

ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.

    at flash.display::DisplayObjectContainer/removeChild()

    at game/onEnterFrame()

ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.

and i guess (not sure) that because the event moves 30 times in sec and when it try to find the if it cant find or child or anything like that

thank you

TOPICS
ActionScript

Views

2.5K

Translate

Translate

Report

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
LEGEND ,
Apr 12, 2012 Apr 12, 2012

Copy link to clipboard

Copied

The error and what you describe sounds like you might be trying to remove something that has already been removed based on what you describe.  If you have already removed the objects, but have not removed the ENTER_FRAME listener that causes it to happen, that could be the source of the problem.

Votes

Translate

Translate

Report

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
Participant ,
Apr 12, 2012 Apr 12, 2012

Copy link to clipboard

Copied

can i download the link in website then send it to you to take look closer ?

Votes

Translate

Translate

Report

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
LEGEND ,
Apr 12, 2012 Apr 12, 2012

Copy link to clipboard

Copied

Try what I said and see if it helps...

        function onEnterFrame(event:Event):void

        {

            

           if(dragonhealthbar.width == 0 ){

            stage.removeChild(fire)

            stage.removeChild(dragonhealthbar)

            stage.removeChild(dragon)  

            removeEventListener(Event.ENTER_FRAME, onEnterFrame);     

       

            }

Votes

Translate

Translate

Report

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
Participant ,
Apr 12, 2012 Apr 12, 2012

Copy link to clipboard

Copied

still the same

Votes

Translate

Translate

Report

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
Participant ,
Apr 12, 2012 Apr 12, 2012

Copy link to clipboard

Copied

is there any another way can i void this problem from it?

Votes

Translate

Translate

Report

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
LEGEND ,
Apr 12, 2012 Apr 12, 2012

Copy link to clipboard

Copied

You should put traces in to see where you might be having these problems.  I just noticed at the start of yiouyr class you have these lines...

        removeChild(b1) 

        removeChild(b2)

        removeChild(c1)

        removeChild(c2)

        removeChild(d1)

        removeChild(d2)

        removeChild(e1)

        removeChild(e2)

How certain are you that by the time this code is executed those objects exist?  You should try putting a trace before them and after each one to see if that is where the error is coming from.

If you have any more remoiveChild calls, you should test there similarly

Votes

Translate

Translate

Report

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
Participant ,
Apr 12, 2012 Apr 12, 2012

Copy link to clipboard

Copied

LATEST

no the game works to the end , every thing fine but when the game over i should remove them all the dragon and hs stuff(and here is the problem),

i.ve tested the project alot of times and it is almost finish i only need to remove the listner ((on enter frame)) because add them so easy but the problem came when i tried to remove them

thank you again brother and you are  realy helpful and lovley person

Votes

Translate

Translate

Report

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