This content has been marked as final. Show 4 replies
That doesn't seem like it is what you want in any event. If the little circles are inside the car clip, then why would you be hitTesting them with the car clip? The second version will always be hitting because the bounding box of the circle will always be inside the bounding box of the car since the circle is inside the car!
The first one is failing for a different reason, I think. In this case it is a problem of frame of reference and/or scope. First if you say the circles are inside the car clip then you need to reference them as car.object.upcircle or car.upcircle.
Next is that object.upcircle._x is going to give the _x value of upcircle RELATIVE TO OBJECT not the stage. So try this using your first bit of code:
You should see that it isn't ever changing (unless you have code to change the position of upcircle inside of its parent object). So I'm guessing the circles are fairly near the origin of the clip they are put into. So if you drive your car into the upper left corner of the screen it should magically work for some small number of spots!
But given that you probably want it to work in more than the upper left corner...then you need to convert the local coordinates to global. Check out localToGlobal() or you can just use a little math.
Should work. I'm going to give you some advice here. I wouldn't call them upcirlce, downcircle, etc. What happens if you realize you need 6 of these or 7 to give a good predictive hit? Instead I would give then names like:
hitSpot0, hitSpot1, etc.
You could then use a little loop to go through all of them instead of having to type out different names for each one. Just a thought.
I am very very sorry Rothrock, Here is the code edited,
The object is a movie clip in which a track has been carved.
Sorry once again,
Can you help me out now,
P.S. The circles are within car mc.
EDIT: Thanks for your quick reply's
Sure thing. Just skip the first sentence of my previous post.
Trace out car.upcircle._x and you will see that it always stays the same because upcircle isn't moving inside of the car clip.
Change the code to
car._x + car.upcircle._x
and that should work. Not an elegant solution but workable.
I still recomment changing the names of your hit dots.
Check out localToGlobal in the help files.