by kirupa | 30
August 2006
The scrollpane is a very useful component that comes
included with
Flash Professional 8. This component allows you to display
content in a viewing area, and if the content is larger than
the viewing area, you get scrollbars with which you can move
the content around. Using the scrollpane is easy for static
movie clips or content stored on your stage or in the
library. It is certainly a lot easier to use than making
your
own!
Because this tutorial requires the
ScrollPane component, you need to use Flash Professional
8 instead of the regular version of Flash.
When you want to use a scrollpane for dynamic movie
clips, though, things can get a bit tricky. That is where
this tutorial comes in, but before I get to that, take a
look at the following you
will create by the end of this tutorial. In the example, keep pressing
the plus/minus arrows to see items being added/removed from
the scrollpane. Notice that the scrollpane's scrollbars
appear when the number of items becomes greater than the
height of the viewing area.
[ click on the plus/minus
buttons to add/remove items from the scrollpane ]
By the end of this tutorial, you will have learned how
to re-create the above functionality. Because much of
the tricks employed deal with the code and some empty
movie clips, I have provided a partial source file
containing the main UI elements that you can re-use
instead:
Download Partial Source
For a more concise,
non-tutorial explanation of how to use dynamic
movie clips using the scrollpane component, check out
Kirupa's blog
post.
In the following pages, I will first explain how to
re-create the above animation. Then I will go through
and explain what each line of code accomplishes so that
you have a better understanding of why loading dynamic
movie clips into a scrollpane works the way it does.
|