Flash Authoring is a huge application and part of its size is due to a
plethora of useful bitmap manipulation tools.  There aren't any built
into Flex, maybe some third-parties have one.
 
You will need to describe in vectors and curves (preferably just
vectors) the outer border of the image.

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of dodtsair
Sent: Tuesday, October 02, 2007 10:19 AM
To: [email protected]
Subject: [flexcoders] Re: actionscript generation of mask/hitArea from
bitmapdata...



--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "unaflux" <[EMAIL PROTECTED]> wrote:
>
> How can I create an arbitrarily complex Shape
> starting from alphachannel data of a dynamically loaded image?
> 
> I'd like to use the shape mainly for two things:
> - to set a complex hitArea of a Sprite
> - to mask a DisplayObject that has MouseEvents on it 
> 
> The problem are somehow related:
> 1) If I apply directly the loaded image 
> (wrapped in a Sprite) as the hitArea
> mousevents gets triggered in the rect area
> that has the dimension of the loaded image.
> 
> 2) If I apply directly the loaded image as a mask
> I've no problems to obtain the visual masking effect
> but mousevents still gets triggered in the rect area
> that has the dimension of the loaded image, not only
> on the visible areas...
> 
> 
> 
> In the authoring environment solution is simple...
> - take the image
> - do a trace bitmap
> - use the traced bitmap non transparent areas 
> as hitArea in a SimpleButton.
> 
> In Actionscript, if the masking/hitArea Shape is simple...
> - draw the masking/hitArea Shape
> - apply it as a mask
> 
> 
> In ActionScript, if the masking/hitArea is complex
> it starts becoming a problem.
> I think that's because I'm still working
> with the BitmapData of the image (that is rectangular).
> Even in the authoring environment if you use a Bitmap,
> instead of a Shape, you get a rectangular mouseSensible area.
> But how can I obtain a Shape from the alphachannel data
> of the image I loaded?
> The idea is to use this arbitrarily complex Shape
> (wrapped in a Sprite) as a dynamically generated mask/hitArea,
> that gives me an arbitrarily complex mouseSensible area.
> 
> Have you ever tried something like that?
> Is that even possible?
> Using Actionscript shouldn't I have access to all that
> could be done in the authoring environment?
> Stated in another way...
> how can I actually do something similar to the 
> trace bitmap operation...
> 
> Any suggestions
> Thanks
> Jo
>

I am trying to do the same thing. I wanted to build a widget that
would allow the user to click on a world map to select his timezone.

At this point like you I have failed to use the hitArea to filter the
mouse events. The next thing I will try is grabing the x,y of the
mouse event and trying to pull out the pixel data of the image at that
point. We'll see if I succeed.

If anyone knows a better more straight forward solution I think we
would both appreciate it.

Mike Power



 

Reply via email to