I have a TextField inside a Sprite and I always want the alpha of the TextField to be equal to the alpha of the sprite. How can i subscribe to the changes made in the Sprite? I guess i need to fire a PropertychangeEvent some how, but I can’t see that sprite supports this out of the box?
class TextWidget extends Sprite{
private var textfield:TextField;
public function TextWidget(){
textfield = new TextField();
textfield.alpha = this.alpha; //does'n help
addChild(textField);
??
this.addEventListener(PropertyChangeEvent.PROPERTY_CHANGE, updateAlpha);
??
}
private function updateAlpha(event:PropertychangeEvent):void{
textfield.alpha = this.alpha;
}
}
One way would be to create a derived class of the sprite and override the alpha property
Another way would simply be to set the textfield alpha whenever the alpha setter of the parent sprite is hit, as shown above just without the event.
Andrew