Flash scrollPane component scrollbar not showing up
Posted By wassim in Flash, Flash TutorialsThis fix applies to flash 8 scrollPane component v2.
Here’s the problem: you attach content dynamically at runtime to your scrollPane, then much to your surprise, the vertical scroll bar doesn’t show up despite the fact that you specified vScrollPolicy as “on” or “auto” and that the content is larger than the scrollPane.
You probably know the problem that’s why you are here! Google dropped you in the right place, I have found a solution! A working fix.
After searching for two hours, and trying all the suggested workarounds like calling the redraw() method on the instance or the onComplete(), doLater() or even the invalidate() method, none of these worked, I even tried lowering the frame rate of the movie but all this ended up failing so I started experimenting and I found the following:
If you change the position of the content clip inside your scroll pane component, the scroll bar will fail to account for this change, it might even not appear in the first place, if you add content dynamically, like attaching a movieClip from the library on runtime, you will also face issues with the scroll bar.
What I did to solve the issue and debug is that I simply called the setSize() method twice, in the first call, I assigned a height higher than the desired one then in the second call, I assigned the desired height and this worked ! the scroll bar of the scrollpane now appears and behaves as expected.
Note that this fixed the case where the content is being attached from the library, not loaded externally.


February 7th, 2008 at 8:20 pm
Similar Issue in Flex 2:
Vertical scroll bar doesn’t show on setting image scaleContent=false.
Fix:
After setting scaleContent=false clear with and percent width and reload image. E.g.
scaleContent=false;
image.width=undefined;
image.percentWidth=undfined;
image.load(image.source);
Took about 2 hours to figure this one out. Hope this helps some Flash developers that are new to Flex.
February 7th, 2008 at 8:26 pm
Typo correction above (for vertical scroll):
scaleContent=false;
image.width=undefined;
image.percentWidth=undfined;
image.load(image.source);
Should be:
scaleContent=false;
image.Height=undefined;
image.percentHeight=undfined;
image.load(image.source);
Also Note:
If you have a need to toggle scaleContent back to true you will need to set the image width and percent width back. Undefined values will only work on scaleContent=false.
Cheers!
February 15th, 2008 at 5:22 am
Thank you very much for putting this up on the web. Means it took me 15mins to solve my problem.