Flex Checkbox Wordwrap
[code lang="as3"]
/**
* @author Christian Mueller
* @date 9/22/2009
* @describtion checkbox with textfield wordwrap true
*/
package components {
import flash.display.DisplayObject;
import flash.text.TextFieldAutoSize;
import mx.controls.CheckBox;
import mx.core.IUITextField;
import mx.core.UITextField;
public class MultilineCheckbox extends CheckBox {
private var multilineLabel : IUITextField;
public function MultilineCheckbox() {
super();
text = "";
}
private var _text : String;
public function set text( value:String ):void {
_text = value;
commitProperties();
}
public function get text():String {
return _text;
}
override protected function createChildren():void {
super.createChildren();
if ( multilineLabel == null ) {
multilineLabel = IUITextField( createInFontContext( UITextField ) );
multilineLabel.text = "";
multilineLabel.wordWrap = true;
multilineLabel.autoSize = TextFieldAutoSize.LEFT;
addChild( DisplayObject( multilineLabel ) );
}
}
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
super.updateDisplayList( unscaledWidth, unscaledHeight );
if ( multilineLabel != null && textField != null ) {
multilineLabel.x = textField.x;
}
}
override protected function commitProperties():void {
super.commitProperties();
if ( multilineLabel != null ) {
multilineLabel.text = _text;
}
}
override protected function measure():void {
super.measure();
}
}
}
[/code]
Beispiel:
Hi Raj, you can use it like this:
checkbox:MultilineCheckbox id="chk" label="Lorem ipsum..."It depends on the package you put this class in. The wordwrap will be done the class itself.
Could you please send me the mxml sample with the multiline checkbox?