I am creating a component that will be a large plus or a large minus. I don't want to use a bitmap because even I can draw this using the Graphics class, but the component mu开发者_运维技巧st be clickable (the Shape class is not).
It will be part of an item renderer, so I want it to be as light-weight as possible. UIComponent does not seem to sent CLICK messages.
Thanks for any ideas
I would suggest creating a Sprite object and drawing the minus and plus arrows to its graphics object. You'll then have to addEventListener(MouseEvent.CLICK, someFunction); in its constructor or wherever else you'll need it.
You may also want to set cacheAsBitmap to true at that point, so that it's not redrawn every frame.
EDIT: Per @jeremynealbrown you have to use the SpriteAsset class if you are working in Flex, apparently. Very similar, but another 2 levels of abstraction are added.
If you look here: UIComponent Docs
You will see that UIComponent has InteractiveObject in its inheritance path. InteractiveObject is the class that adds mouse event functionality.
UIComponent will actually dispatch click events. However, if there is no content drawn to the graphics, the UIComponent will have no area that can be clicked. If the plus or minus icon you draw is too small to reliably catch mouse activities, then draw a fully-transparent rectangle to increase the hit area.
精彩评论