Changing Flex3 ScrollBar maxScrollPosition at runtime

7 May 2008, 18:16, by Jon

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.

 
		<!--[CDATA[
			private function handleSlideChange():void {
				scroll.maxScrollPosition = slider.value;
				scroll.invalidateDisplayList();
			}
		]]-->





7 comments below:


Great. It worked for me. Thanks for posting the solution.

Comment by Karthik — 15 August 2008 @ 20:09

Great!!! It works!
Thanx!
You are GROSSO!!

Comment by Allen — 30 October 2008 @ 14:06

Great work. But somehow I am not being able to run this in my project. Can u gimme a detailed example? Or is it any FLEX SDK version specific? I have noticed that this bug is mentioned in Adobe’s site. Although they have said that this bug has been resolved in Flex 3.0.X version.
Best regards
Dipz
——————
http://www.webvariations.com

Comment by Dipz — 27 November 2008 @ 09:58

Excellent, was going nuts trying to figure this one out.

Comment by Matt Wilson — 26 December 2008 @ 17:41

thanks, you saved me a lot of time :)

Comment by sydd — 10 January 2009 @ 02:32

Thanks, was going nuts too. And would be nice if you fix this, Adobe ..

Comment by Marc Haemmerle — 12 March 2009 @ 10:12

Leave a comment

About Jon

Jon started his career hacking code on his Sinclair Spectrum before moving on to more sophisticated machines ( ...such as a Commodore 64 ). He graduated from the University of Kent in 2000 with a degree in Computer Science and since then has worked in finance and education before co-founding Go Tripod. He is passionate about usability and design and his favourite development technologies are Ruby, and Objective-C/Cocoa. When he is not sat at his desk he is standing on his head doing yoga, refining his taste for food or on an adventure exploring the great outdoors.

Go Tripod Ltd

Go Tripod Ltd is a UK-based development company working with some of the most exciting software technologies around. Simon Ashley, Jon Baker and Colin Ramsay are the brains behind projects such as Stubmatic, and are developing bespoke web, mobile and desktop software for clients with household names. We believe in good service as well as good software, and we’re eager to work with people who feel the same.