Question

when i use the following tree renderer class the the informtions in the tree gets chopped. Is there any solution to fix this bug. please help me. The PLTree class is as follows:

import flash.events.Event;
    import mx.events.ScrollEvent;
    import mx.controls.Tree;
    import mx.core.ScrollPolicy;
    import mx.core.mx_internal;
    import mx.events.TreeEvent;

    public class PLTree extends Tree
    {
        private var _lastWidth:Number = 0;
        private var _lastHeight:Number = 0;
        public function PLTree() {
            super();
            horizontalScrollPolicy = ScrollPolicy.AUTO;
        }       
       override public function get maxHorizontalScrollPosition():Number
       {
            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);

            if (diffWidth <= 0) {
                maxHorizontalScrollPosition = 0;
                horizontalScrollPolicy = ScrollPolicy.OFF;
            } else {
                maxHorizontalScrollPosition = diffWidth;
                horizontalScrollPolicy = ScrollPolicy.ON;
            }
            super.updateDisplayList(unscaledWidth, unscaledHeight);
       }
    override protected function scrollHandler(event:Event):void
    {
        if (mx_internal::isOpening)
            return;

        // TextField.scroll bubbles so you might see it here
        if (event is ScrollEvent){

            super.scrollHandler(event);
            invalidateDisplayList();
        }
    }   
}

i am attaching the image file of how it looks when executed. enter image description here

When surfing using google i found a suggesion to fix this bug is it the right way ? (

Issue: Text getting chopped of at end.
Fix: change
maxHorizontalScrollPosition = diffWidth;
to
maxHorizontalScrollPosition = diffWidth + 10;
or what ever correction factor you need. 

)

Kindly help me .Thanks a lot in advance.

Was it helpful?

Solution 2

similar to the scroll handler in the above mentioned program. Use a mouse wheel scroll handler to handle that event as follows:

override protected function mouseWheelHandler(eventMouse:MouseEvent):void
     {      if (mx_internal::isOpening)
            return;

        if (eventMouse is MouseEvent){          
            super.mouseWheelHandler(eventMouse);
            invalidateDisplayList();
        }
     }

OTHER TIPS

Looking at your picture, I'd suspect the issue has nothing to do with the specific tree, and is only slightly related to the renderer. Instead, I think that when the container holding the Tree is created, it doesn't have a size, and when the Tree sizes its renderers, it gives them the wrong size. Since List-based controls don't set the actual width on renderers, choosing to set explicitWidth instead, the renderers aren't triggered into changing their size.

Check out http://www.developria.com/2009/12/handling-delayed-instantiation-1.html for more explicit details and fixes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top