topical media & game development
professional-flex-code-13-ValidateButton.ax
professional-flex-code-13-ValidateButton.ax
[swf]
flex
package
{
// import statements
import mx.controls.Button;
// class name
public class @ax-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 @ax-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+")";
}
}
}
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.