1

I would like my application to show every disabled UIComponent on stage with a certain amount of alpha on it.

I believe the default value is .5 and this makes some of the fields quite unreadable. Reducing it to .3 should fix my problem.

  • For Spark components, I know I can create a custom skin and edit the alpha.disabled. But I don't want to do this for 30+ components just for the sake of an alpha style property

  • Setting disabledOverlayAlpha will only work on containers, and I need something that actually will work on components at the lowest level of the dislay hierarchy. If I'm not mistaken this is only available for mx components.

What would be the pragmatic way to go in order to make all UIComponents show the same amount of alpha on disabling them?

Cheers

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
Dennis Jaamann
  • 3,547
  • 2
  • 23
  • 42

1 Answers1

1

Not the prettiest solution, but it's the only thing I could come up with that does what you ask for any UIComponent:

  • Listen to Event.ADDED on the stage, so you catch every component that is added to the displayList.
  • Start listening for "enabledChanged" on the event's target (which is the component that was just added). "enabledChanged" is dispatched by UIComponent when its enabled property changes.
  • Set the alpha of the component that fires this event.
  • Also don't forget to clean up those event listeners when the component is removed from the stage or you'll get serious performance issues.
  • For Spark components you'll probably have to override the Skin's default disabled alpha value somehow. This may require listening for the skin's StateChangeEvent.CURRENT_STATE_CHANGE.

Yuck! I hope I'm overlooking a simpler option. Otherwise I'd probably just go for creating all the Spark skins, perhaps with an additional style for the disabled alpha value so that you can set it globally in the future.

RIAstar
  • 11,912
  • 20
  • 37
  • Yeah that's indeed what I feared as well. And I was hoping to overlook an easier solution too :P Problem I see with such workarounds is that they will easily generate bug reports whenever forgetting to add the same workaround in one of many places. Also, I strongly believe in the DRY principle, which in this case is void. – Dennis Jaamann Jan 31 '13 at 18:54
  • @DennisJaamann Perhaps you misunderstood: if you listen on the stage, this would have to be implemented only once; no repeating involved. I would just hate to hook up so many event listeners only for the sake of setting an alpha property. – RIAstar Jan 31 '13 at 19:11
  • you are correct :) I should've been more clear in my comment. For the mx components, indeed one place only would suffice. However in most screens we have somewhere between 50 - 100 UI components. Listening to the stage and adding eventlisteners.. I have my concerns about that one :) For Spark, I would indeed need to override the default alpha somehow. Imho this would require us to create a custom skin for every componenten, hence my remark about having to make this change in all sorts of places. Cheers – Dennis Jaamann Feb 01 '13 at 08:36
  • @DennisJaamann That's why I suggested listening for StateChangeEvent.CURRENT_STATE_CHANGE on the component's skin, so you could set its alpha value _after_ it was internally set through States. I agree this could become pretty messy though. – RIAstar Feb 01 '13 at 09:48
  • +1 for your elaborate answer/ commenting. I'm glad we both agree on the fact that this can get rather messy real quick :) – Dennis Jaamann Feb 01 '13 at 10:16