본문 바로가기

카테고리 없음

FLEX LinkBar Extend Component


프로젝트 진행중 필요하게 되어 만들고 있는 UserCompopnent 기존에 모듈이 조금 속도도 느리고

해서 새롭게 들어가는 Component인데.. 과연 얼마나 성능이 좋아 질까 궁금하다.. ^^

ExtendLinkBar.as

package flexlib.Controls.LinkBar
{
	import flash.events.MouseEvent;
	
	import flexlib.Skin.CustLinkbuttonSkin;
	
	import mx.controls.LinkBar;
	import mx.controls.LinkButton;
	
	import mx.controls.Alert;
	
	public class ExtendLinkBar extends LinkBar
	{
		public function ExtendLinkBar()
		{
			super();
		}
		
		protected override function childrenCreated():void
		{
			super.childrenCreated();
			
			var _ChildArray:Array = this.getChildren();
			
			for each(var _LinkButton:LinkButton in _ChildArray)
			{
				if(_LinkButton is LinkButton)
				{
					_LinkButton.setStyle("textRollOverColor","#FFFFFF");
					_LinkButton.setStyle("textSelectedColor","#FF0000");
					_LinkButton.setStyle("color","#00FF00");
					_LinkButton.setStyle("skin", flexlib.Skin.CustLinkbuttonSkin);
					_LinkButton.toggle = true;
				}
			}
		}
		
		protected override function clickHandler(event:MouseEvent):void
		{
			super.clickHandler(event);
			
			var _Button:LinkButton = event.currentTarget as LinkButton
			
			var _ChildControls:Array = this.getChildren();
			
			for each(var _LinkButton:LinkButton in _ChildControls)
			{
				_LinkButton.enabled = true;
			}
			
			_Button.enabled = false;
		}			
	}
}

CustLinkbuttonSkin.as
package flexlib.Skin
{
	import mx.skins.halo.LinkButtonSkin;
	
	public class CustLinkbuttonSkin extends LinkButtonSkin
	{
		public function CustLinkbuttonSkin()
		{
			super();
		}
		
		override protected function updateDisplayList(w:Number, h:Number):void
		{
			super.updateDisplayList(w, h);
			
			graphics.clear();		 			
						
			switch (name)
			{
				case "upSkin":					
					break;
				case "selectedUpSkin":
				case "selectedOverSkin":									
					break;
				case "overSkin":					
					break;
				case "selectedDownSkin":
				case "downSkin":					
					break;
				case "selectedDisabledSkin":
				case "disabledSkin":
					drawRoundRect(0, 0, w, h, 4, 0xffffff, 1);
					break;
			}
		}		
	}
}

보는 코드 처럼 LinkBar에 Skin을 주는 UserComponent인데.. 메뉴에서 필요하여 만들게 되었다..

주석은 참고로.. 생략.. ^^