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

hitTestObject works for one mc but not for the other

Participant ,
Jul 11, 2012 Jul 11, 2012

Copy link to clipboard

Copied

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

                        }

                   

                   

               

        }

TOPICS
ActionScript

Views

464

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

correct answers 1 Correct answer

LEGEND , Jul 11, 2012 Jul 11, 2012

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.

Votes

Translate

Translate
LEGEND ,
Jul 11, 2012 Jul 11, 2012

Copy link to clipboard

Copied

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.

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 ,
Jul 11, 2012 Jul 11, 2012

Copy link to clipboard

Copied

LATEST

Wow - I feel stupid.

Sorry for wasting your time - I was looking for something real complicated and forgot to carefully read over every line. (happens to me a lot)

Cheers

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