Transparency png issues with creating a Flash Map in Flash CS4

Posted on 2010-01-07
Last Modified: 2013-11-12
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?
Question by:far2cool
    LVL 13

    Expert Comment

    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.
    LVL 19

    Expert Comment

    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 : )
    LVL 14

    Accepted Solution

    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.
    LVL 12

    Expert Comment

    crooksy88 is solution.

    Author Comment

    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!).
    LVL 14

    Expert Comment

    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.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
    While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
    The purpose of this video is to demonstrate how to Test the speed of a WordPress Website. Site Speed is an important metric of a site’s health. Slow site speed can result in viewers leaving your site quickly and not seeing your content. This…
    The purpose of this video is to demonstrate how to update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now