package
{
import flash.events.MouseEvent;
import flash.utils.getQualifiedClassName;

import mx.controls.HSlider;
import mx.core.UIComponent;
import mx.core.mx_internal;

use namespace mx_internal;

/**
 *  A custom HSlider which can  show dataTip when mouseOver,
 *  and destroy it when mouseOut.
 * 
 * @author Ethan Du @date 2010-01-25
 * 
 */
public class TipHSlider extends HSlider
{
	public function TipHSlider()
	{
		super();
		
		addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
		addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
	}
	
	private function onMouseOver(e:MouseEvent):void
	{			
		/* var u:UIComponent = mx_internal::innerSlider;
		for(var i:int=0; i<u.numChildren; i++)
		{
			trace(getQualifiedClassName(u.getChildAt(i)))
			if(u.getChildAt(i) is UIComponent)
			{
				trace( UIComponent(u.getChildAt(i)).numChildren );
			}
		} */
		
		// if you want to know why the fourth child,
		// please check the source code of Slider.as .
		mx_internal::onThumbPress(  UIComponent(mx_internal::innerSlider.getChildAt(3) ).getChildAt(0) );
	}
	
	private function onMouseOut(e:MouseEvent):void
	{
		if (mx_internal::dataTip)
        {
            systemManager.toolTipChildren.removeChild(mx_internal::dataTip);
            mx_internal::dataTip = null;
        }
	}

}
}
