TextInputでのアイコンの設定
package
{
import flash.display.DisplayObject;
import mx.controls.Image;
import mx.controls.TextInput;
import mx.core.mx_internal;
use namespace mx_internal;
public class MyTextInput extends TextInput
{
private var _image:Image;
public function MyTextInput()
{
super();
}
override protected function createChildren():void
{
super.createChildren();
_image = new Image();
_image.source = "search.png";
addChild(DisplayObject(_image));
}
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
this._image.width = 16;
this._image.height = 16;
this._image.x = 0;
this._image.y = (this.height - this._image.height)/2;
this.textField.x = this._image.width+2;
this.textField.y = (this.height - this.textField.height)/2;
this.textField.width = this.width - this._image.width-5;
//this.setStyle("paddingLeft",this._image.width+2);
}
}
}
比較的簡単な実現方法ですが、ネット上ではあまり調べられません.これはやはり外網blogで調べたもので、自分で修正して、自分でmacの検索を真似たアイコンが右側にあって、左に変更しました.谁が良い解决策があって、出して研究します!!!o(∩∩)oハハハ