Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Turning a dynamic image into a selectable area

Status
Not open for further replies.

Marcus9

Programmer
Jan 5, 2001
7
GB
I am drawing a shape made up of lines with the coordinates obtained from a
database. How do I make the area inside of the lines into a selectable
object or enable a hitTest upon it. Has anyone else ever tried this or are
there any examples anywhere?

cheers,
Marcus.
 
I've never seen this done before and depending on whether you want to follow a complex shape and generate an exact hit area image or not I'm not sure even if it could be done.

The only thing I can think of in the first instance is reusing the coordinates used to generate the lines to scale an invisible button to the rough shape and size of the enclosed area.

If you're drawing the lines using the old "100 pixel line rescaling trick" creating the button would be simple enough.

Take the vertices of the shape, subtract the leftmost _x coord from the rightmost _x coord and the topmost y coord from the bottom-most (is that a word?) _y coord which would give you an _xscale and a _yscale parameter. Then use these values to resize a 100 pixel square movie clip, which is only comprised of an invisible button, to the rough size and shape of your target clip.

It won't exactly fit complex polygons and it might stick out here and there but, depending on what you need it for, it might be close enough...

To get it a closer fit you'd have to generate a mathematical model of the enclosed area using the database coordinates and then check the _xmouse and _ymouse positions to see if they fell within that area.

Tricky...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top