0

Hi Guys an Gals
I am trying to make a small game just for fun and have hit a wall though am sure the answer is so simple. Its so foggy here anyway:-)
I have a rolling displayobject calles Roller that goes back and forth across the screen. In its path from time to time are other DisplayObjects. I need to get the name of the object that Roller hits and pass to a switch statement.
The follow code snippet compiles and the hit is detected but the switch always returns default: Does anyone have any idea how to solve this please. Best regards, Frederick.

  if (theRoller.hitTestObject(target)) 
                    { 
                    trace("Current target"); // [object Erikpl]

                        switch (target)
                        {
                             case "[object Erikpl]"):
                             trace(" Erikpl Hit",target);
                             break;

                             default:
                            //trace ("Nothing was selected, solve the problem");
                         }
                    }
2
Contributors
1
Reply
4
Views
4 Years
Discussion Span
Last Post by firstPerson
0

what language is this? Its hitting default because none of the cases match, try printing out target and see what it shows and try to match it to the case statement. You might just want to check if target contains('Erikpl') to avoid the extra stuff.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.