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 哈哈
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值