Flex tree automatically displays horizontal scroll bar implementation code _flex

Source: Internet
Author: User
Copy Code code as follows:

Package com.anydata.consumer.components
{
Import flash.events.Event;
Import Mx.controls.Tree;
Import Mx.core.ScrollPolicy;
Import mx.core.mx_internal;

/**
* Automatic display of horizontal scroll bar
*/
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);
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.