`
bootong
  • 浏览: 11342 次
  • 性别: Icon_minigender_1
  • 来自: 西安
社区版块
存档分类
最新评论

TextInput中设置图标

    博客分类:
  • flex
阅读更多
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 哈哈
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics