您当前的位置: 首页 > 

Jave.Lin

暂无认证

  • 3浏览

    0关注

    704博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

AS3 ComboBox ---- 下拉列表框类,又是细节是魔鬼啊

Jave.Lin 发布时间:2012-04-11 20:13:37 ,浏览量:3

ComboBoxDropDownButton类(下拉列表框的按钮类):

package
{
	/**
	 * 下拉列表框的按钮类
	 * @author Jave.Lin
	 */	
	public class ComboBoxDropDownButton extends Button
	{
		private var _rateX:Number=1;
		private var _rateY:Number=1;
		
		public override function set width(value:Number):void
		{
			if(super.width!=value)
			{
				super.width=value;
				_rateX=value/10;
				refreshBackground();
			}
		}
		
		public override function set height(value:Number):void
		{
			if(super.height!=value)
			{
				super.height=value;
				_rateY=value/10;
				refreshBackground();
			}
		}
		
		public function ComboBoxDropDownButton()
		{
			super();
			
			width=10;
			height=10;
		}
		
		protected override function refreshBackground():void
		{
			//super.refreshBackground();
			
			//背景也居中
			this.graphics.clear();
			this.graphics.beginFill(0x55aa00, 0.1);
			this.graphics.drawRect(0,0,10*_rateX,10*_rateY);
			this.graphics.endFill();
			
			//边框
			this.graphics.moveTo(0,0);
			this.graphics.lineStyle(1,0,.5);
			this.graphics.lineTo(10*_rateX,0);
			this.graphics.lineTo(10*_rateX,10*_rateY);
			this.graphics.lineTo(0,10*_rateY);
			this.graphics.lineTo(0,0);
			
			//三角形
			this.graphics.moveTo(5*_rateX,8*_rateY);
			this.graphics.lineStyle(1,0,.5);
			this.graphics.lineTo(8*_rateX,2*_rateY);
			this.graphics.lineTo(2*_rateX,2*_rateY);
			this.graphics.lineTo(5*_rateX,8*_rateY);
		}
	}
}
ComboBox下拉列表框类:

package
{
	import controlsEvents.ComboBoxEvent;
	import controlsEvents.OptionsListEvent;
	
	import flash.display.Bitmap;
	import flash.display.Shape;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.filters.GlowFilter;

	/**
	 * 下拉列表框类
	 * @author Jave.Lin
	 */	
	public class ComboBox extends Control
	{
		private var _background:Shape;//背景
		private var _glowFilter:GlowFilter;
		private var _showSelectedItem:Option;//显示在当前选中框中的子项
		private var _optionsList:OptionsList;
		private var _dropDownBtn:ComboBoxDropDownButton;//下拉按钮
		
		public override function get width():Number
		{
			return super.width;
		}
		
		public override function set width(value:Number):void
		{
			if(width!=value)
			{
				_w=value;
				
				if(_w            
关注
打赏
1664331872
查看更多评论
0.0799s