0

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 must 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

Richard Haven
  • 1,122
  • 16
  • 31

3 Answers3

2

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.

Jeremy White
  • 2,818
  • 6
  • 38
  • 74
1

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.

sberry
  • 128,281
  • 18
  • 138
  • 165
1

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.

Josh Tynjala
  • 5,235
  • 3
  • 23
  • 25