欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

flex tree自动显示横向滚动条实现代码

程序员文章站 2022-03-07 18:38:37
复制代码 代码如下: package com.anydata.consumer.components { import flash.events.event; import...
复制代码 代码如下:

package com.anydata.consumer.components
{
import flash.events.event;
import mx.controls.tree;
import mx.core.scrollpolicy;
import mx.core.mx_internal;

/**
* 自动显示横向滚动条
*/
public class autosizetree extends tree
{
public function autosizetree()
{
super();
horizontalscrollpolicy=scrollpolicy.auto;
}

override public function get maxhorizontalscrollposition():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"));
scrollareachanged=true;
invalidatedisplaylist();
}

override protected function updatedisplaylist(unscaledwidth:number, unscaledheight: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);
}
}
}