package{ import flash.events.Event; import mx.controls.Tree; import mx.core.mx_internal; import mx.core.ScrollPolicy; import mx.events.TreeEvent; public class AutoSizeTree extends Tree { public function AutoSizeTree(){ super(); horizontalScrollPolicy = ScrollPolicy.AUTO; } // we need to override maxHorizontalScrollPosition because setting // Tree's maxHorizontalScrollPosition adds an indent value to it, // which we don't need as measureWidthOfItems seems to return exactly // what we need. Not only that, but getIndent() seems to be broken // anyways (SDK-12578). // I hate using mx_internal stuff, but we can't do // super.super.maxHorizontalScrollPosition in AS 3, so we have to // emulate it. 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 { // we call measureWidthOfItems to get the max width of the item renderers. // then we see how much space we need to scroll, setting maxHorizontalScrollPosition appropriately var diffWidth:Number = measureWidthOfItems(0,0) - (unscaledWidth - viewMetrics.left - viewMetrics.right); if (diffWidth <= 0) maxHorizontalScrollPosition = NaN; else maxHorizontalScrollPosition = diffWidth; super.updateDisplayList(unscaledWidth, unscaledHeight); } } }
Sunday, September 09, 2007
AutoScrolling for Flex Tree
Re-Introduction
For some technical reasons, I had to repost this introduction, but I'm also going to start blogging for real now. I have Internet at home, and we're getting a little more free time at work as we're almost done bug fixing for the next release. Anyways, on to the introduction.
Who are you? I am Ryan Frishberg, and I just graduated from Carnegie Mellon University. In July, I moved out to the Bay Area and started work at Adobe on the Flex SDK team. I’ve always been interested in software development and web technology, and Flex is absolutely awesome.
Why are you blogging now? Since I’ve tried to stay on top of the Web 2.0 and Rich Internet Application world, I read way too many blogs each day. I found out that through all the jargon propaganda they give you (don’t worry, I’ll be dosing out similar content soon), the blogs are actually useful. In fact, about half the time I Google for a technical question, I end up going to a blog. So I hope that by starting this blog, I can contribute to some of the technical knowledge (as well as the proper jargon and propaganda) out there. Also, I just started working on Flex, which means that I’ll have some really cool issues to talk about
What will I talk about in the blog? I would like to talk about web technologies, especially Flex. I’ll give examples on using Flex for beginners to show you how easy it is to create something useful in the framework. I also hope to cover more advanced topics that aren't covered as much by other blogs, like bugs I'm currently working on or limitations to the framework.
Content is on its way soon, and if you want to reach me with any questions, feel free to contact me via email.