Archive for May, 2008
May
7Changing Flex3 ScrollBar maxScrollPosition at runtime
7
Posted: 7th May 2008
Posted in Uncategorized
Comments: 1 Comment »
A quick tip if you have a dynamic scroll bar and want to bind it’s maxScrollPosition to a value at runtime unfortunately you can’t use the MXML binding, i.e. maxScrollPosition={value}.
Alternatively you need to set the value programatically in an event handler, AND importantly call updateDisplayList() on the scrollbar. i.e.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"> <mx:Script> <![CDATA[ private function handleSlideChange():void { scroll.maxScrollPosition = slider.value; scroll.invalidateDisplayList(); } ]]> </mx:Script> <mx:HSlider minimum="1" maximum="10" value="1" tickInterval="1" liveDragging="true" id="slider" width="50%" change="handleSlideChange()" snapInterval="1"/> <mx:HScrollBar scrollPosition="0" width="50%" id="scroll" pageSize="1"/> </mx:Application> |
play="true"
loop="false"
quality="high"
allowScriptAccess="sameDomain"
type="application/x-shockwave-flash"
pluginspage="http://www.adobe.com/go/getflashplayer">



