package { // import statements import mx.controls.Button; // class name public class professional_flex_code_13_ValidateButton extends Button { // define properties [Embed(source="good.png")] private var checkIcon:Class; [Embed(source="bad.png")] private var xIcon:Class; private var _isValid:Boolean; // default constructor public function professional_flex_code_13_ValidateButton (){ // a good practice is to include a call to super(). super(); this.setStyle("icon",xIcon); } // getters and setters public function get isValid():Boolean{ return this._isValid; } public function set isValid(b:Boolean):void{ this._isValid = b; if(b){ this.setStyle("icon",checkIcon); }else{ this.setStyle("icon",xIcon); } } // a method to return propeties public function getProperties():String{ var s:String = "Label = " + this.label + "\n" + "Width = " + this.width + "\n" + "Height = " + this.height; return s; } // an override to add parentheses to the label override public function get label():String{ return "("+super.label+")"; } } }