Flash scrollPane component scrollbar not showing up

This 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.

 

Leave a Reply