Skip navigation
Currently Being Moderated

hitTestObject works for one mc but not for the other

Jul 11, 2012 3:14 AM

Hi - I have given instance names to two movieclips for "bee" and "energy". When I sling the "ball" up and it hits the bee all the code executes but when I sling and hit the energy nothing happens. Thanks for any help.

 

function onMyEnterFrame(evt:Event):void

        {

                              bee.x +=1;

                    if (bee.hitTestObject(energy))

                        {

                            trace("energy");

                            //beeHit=true;

                            energy.visible = false;

                            power.x = energy.x

                            power.y = energy.y

                            this.addChild(power);

                        }

                    if (bee.hitTestObject(ball) && beeHit==false)

                        {

                            trace("gotcha");

                            beeHit=true;

                            bee.visible = false;

                            pop_mc.x = bee.x

                            pop_mc.y = bee.y

                            this.addChild(pop_mc);

                        }

                   

                   

               

        }

 
Replies
  • Currently Being Moderated
    Jul 11, 2012 4:25 AM   in reply to codeBeastAdobe

    You might be experienciung some confusion with your names in the coding.  I don't see anywhere where ball is checked for a hitTest with energy... the first conditional tests if bee hits energy, not ball.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points