Flex verticalScrollPolicy bug


When you have content with width set to 100%, and verticalScrollbarPolicy set to auto, when you resize the window so the vertical scrollbar is needed, you would expect the content area to adjust to handle the newly added vertical scrollbar, but it doesn't. What happens instead is a horizontal scrollbar appears.

To reproduce this bug:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:local="*">
	<mx:Canvas width="100%" height="700"/>

Here's my workaround. I manually toggle the vertical scrollbar instead of using ScrollPolicy AUTO.

// In your Application or wherever you need this workaround.
override public function validateSize(recursive:Boolean = false):void {
	if (!initialized) return;
	if (height < measuredHeight) verticalScrollPolicy = ScrollPolicy.ON;
	else verticalScrollPolicy = ScrollPolicy.OFF;

Flash Builder throws the following error (compiling to Flex 3.5)
1120: Access of undefined property ScrollPolicy.
line 138 Flex Problem

make sure you import ScrollPolicy. Just hit ctrl + spacebar with your cursor after ScrollPolicy.

That was it. I hadn't imported ScrollPoilicy. Thanks again!

been searching and scratching my head for hours!! this fixed it!

It's just great! Thanks!

This did not solve my problem. I tried to adapt the same thing with the horizontalScrollPolicy.
override public function validateSize(recursive:Boolean = false):void {
if (!initialized) return;
if(width < measuredWidth) horizontalScrollPolicy = ScrollPolicy.ON;
else horizontalScrollPolicy = ScrollPolicy.OFF;

To see if the horizontalScrollPolicy would turn on automatically without overlapping the content.

Thx a lot for this helpful post!!!

my boss sends me a link to your site to fix a bug you've told me about in person...

You saved me a lot of time.
God bless you :-)

This saved me a bunch of time. -K

Awesome, such a simple solution to a problem that has bugged me for ages.

Found this from http://stackoverflow.com/questions/292826/flex-prevent-scrollbar-from-co... so you've probably helped a bunch of other people too :D