package com.anydata.consumer.
components
{
import flash.events.Event;
import mx.controls.Tree;
import mx.core.Scroll
policy;
import mx.core.mx_internal;
/**
* 自动显示横向滚动条
*/
p
ublic class AutoSizeTree extends Tree
{
public function AutoSizeTree()
{
su
PEr();
horizontalScrollPolicy=ScrollPolicy.AUTO;
}
override public function get maxHorizontalScrollPos
ITion():Number
{
if (isNaN(mx_internal
::_maxHorizontalScrollPosition))
return 0;
return mx_internal::_maxHorizontalScrollPosition;
}
override public function set maxHorizontalScrollPosition(value:Number):void
{
mx_internal::_maxHorizontalScrollPosition=value;
dispatchEvent(new Event("maxHorizontalScrollPositionChanged"));
scrollAr
eachanged=true;
invalidateDis
playList();
}
override
PRotected function updateDisplayList(unscaledWidth:Number, unscaledH
eight:Number):void
{
VAR diffWidth:Number=measureWidthOfItems(0, 0) - (unscaledWidth - viewMetrics.left - viewMetrics.right);
var indentation:Number=getStyle("indentation");
if (diffWidth <= 0)
maxHorizontalScrollPosition=NaN;
else
maxHorizontalScrollPosition=diffWidth + indentation;
super.updateDisplayList(unscaledWidth, unscaledHeight);
}
}
}