0

I have a spark button subclass with a custom skinclass, defined as follows:

<s:Button xmlns:fx="http://ns.adobe.com/mxml/2009"
      xmlns:s="library://ns.adobe.com/flex/spark"
      skinClass="com.company.NvrControlButtonSkin"
      enabled="false">

I have then in the script part of this button subclass a setter for an object, where I register a property listener on that object. In the listener, I need to set a property on the skin itself. However, it happens that the object returned by the skin property is not yet of the type I set on the skinClass. I assume that my property listener is already called before the actual skin is set. I would now like to be notified when the skin property is actually changed, so that I then can set the properties on the skin object that are needed.

Is there anything I can listen to or a method that I can override or something to be notified that the skin is actually set to my custom skin now ?

zero323
  • 322,348
  • 103
  • 959
  • 935
Wim Deblauwe
  • 25,113
  • 20
  • 133
  • 211

1 Answers1

0

You're in luck, this is an easy fix. SkinnableComponent (and hence also Button) implements the following two protected methods, which you can override:

  • attachSkin(), called every time a new skin is applied to the component
  • detachSkin(), called when the current skin is removed from the component

That said, I would try to avoid setting properties directly on the skin, because it creates a tight coupling between host component and skin. Try to update properties by using skin parts.

RIAstar
  • 11,912
  • 20
  • 37