Transparency png issues with creating a Flash Map in Flash CS4

Hi everyone, I'm having a problem at the moment as I try to create a Flash map of England. I've imported transparent png images of all the different counties within England and converted them into rollover buttons. Every single county button has its own layer on the timeline, but the problem arises as the mouse detects the square box around each png image and not the county outline within. I want the 'hit area' for each button to just be non-transparent part of the png.

Does anyone have any simple ideas on how I could get round this problem?
Who is Participating?
TanLiHaoConnect With a Mentor Commented:
Like what crooksy88 said, you can't use the transparency to determine hit areas. There is no simple solution too to determine where is the transparency using Actionscript like what moagrius said.

But here's a trick, in the up, over, and down state of your button, you might want to keep the bitmap. In the hit area, duplicate your bitmap and place it there. Click the bitmap, you should be able to see the border around the transparency, if you don't. There is no transparency.

If there is, press ctrl b on the bitmap. Go to the properties panel, you should now see it as a shape. Of course, you might realise that you can only select the entire shape and not the individual portions. Now deselect the shape. Click the lasso tool, go to the context-sensitive option in the tools panel, i.e. should be near the bottom of the tools panel. Click on the transparent part of the shape. The transparent part should now be selected. Press delete, the transparent portion will be gone.

If you get other parts of the shape being deleted when you use the magic wand. Click the magic wand settings, which is below the magic wand when you select lasso tool. Change the threshold to 0 and redo the above steps.
You won't be able the use the transparency to determine hit areas. The best way around this is to create vector shapes and turn them into button symbols.
You asked for a "simple" solution - and crooksy88 is right - your best best would be to use vectors.  If it's not feasible to recreate them in the Flash API, you can take the layers from photoshop to Illustrator and save them as vectors there, then import those directly to flash.

If that too isn't feasible for you, you could technically use a mouseMove handler with Bitmap and BitmapData methods to check the color of the pixel beneath the pointer using getPixel32, and if it's not transparent, react.  But that's definitely not a simple solution : )
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

crooksy88 is solution.
far2coolAuthor Commented:
Thank you everyone for the quick replies. TanLiHao your solution worked perfectly, thank you for the clear and concise instructions. I am now just deleting the transparent background of each png image in the hit state of the button and means I can keep all of my existing png's in my Flash project (as they were neatly arranged!).
Sorry for posting but I have waited a day and I thought you might have forgot about assigning points to the solutions that helped you.

You might want to assign the one that answered your question entirely as the accepted solution and for the assisted solutions, you might want to give the points to those who help you clarify some concepts related to your question.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.