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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.