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

编程学习 2021-07-05 11:32www.dzhlxh.cn编程入门
flex tree自动显示横向滚动条想必有很多的朋友都不会吧,狼蚁网站SEO优化与大家分享下具体的实现方法,感兴趣的你可不要错过了哈
代码如下:

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);
}
}
}

Copyright © 2016-2025 www.dzhlxh.cn 金源码 版权所有 Power by

网站模板下载|网络推广|微博营销|seo优化|视频营销|网络营销|微信营销|网站建设|织梦模板|小程序模板