|
Using the ScrollPane component
You can use a scroll pane to display any content that is
too large for the area into which it is loaded. For example,
if you have a large image and only a small space for it in
an application, you could load it into a scroll pane.
You can set up a scroll pane to allow users to drag the content
within the pane by setting the scrollDrag parameter to true;
a pointing hand appears on the content. Unlike most other
components, events are broadcast when the mouse button is
pressed and continue broadcasting until the button is released.
If the contents of a scroll pane have valid tab stops, you
must set scrollDrag to false; otherwise each mouse interaction
with the contents will invoke scroll dragging.
Related topics
ScrollPane parameters
Creating an application with the ScrollPane component
ScrollPane parameters
You can set the following authoring parameters for each ScrollPane
instance in the Property inspector or in the Component inspector:
contentPath indicates the content to load into the scroll
pane. This value can be a relative path to a local SWF or
JPEG file, or a relative or absolute path to a file on the
Internet. It can also be the linkage identifier of a movie
clip symbol in the library that is set to Export for ActionScript.
hLineScrollSize indicates the number of units a horizontal
scroll bar moves each time an arrow button is clicked. The
default value is 5.
hPageScrollSize indicates the number of units a horizontal
scroll bar moves each time the track is clicked. The default
value is 20.
hScrollPolicy displays the horizontal scroll bars. The value
can be on, off, or auto. The default value is auto.
scrollDrag is a Boolean value that determines whether scrolling
occurs (true) or not (false) when a user drags on the content
within the scroll pane. The default value is false.
vLineScrollSize indicates the number of units a vertical
scroll bar moves each time a scroll arrow is clicked. The
default value is 5.
vPageScrollSize indicates the number of units a vertical
scroll bar moves each time the scroll bar track is clicked.
The default value is 20.
vScrollPolicy displays the vertical scroll bars. The value
can be on, off, or auto. The default value is auto.
You can write ActionScript to control these and additional
options for a ScrollPane component using its properties, methods,
and events. For more information, see ScrollPane class.
Creating an application with the ScrollPane component
The following procedure explains how to add a ScrollPane component
to an application while authoring. In this example, the scroll
pane loads a SWF file that contains a logo.
To create an application with the ScrollPane component:
Drag a ScrollPane component from the Components panel to the
Stage.
In the Property inspector, enter the instance name myScrollPane.
In the Property inspector, enter logo.swf for the contentPath
parameter.
Select Frame 1 in the Timeline, open the Actions panel, and
enter the following code:
scrollListener = new Object();
scrollListener.scroll = function (evt){
txtPosition.text = myScrollPane.vPosition;
}
myScrollPane.addEventListener("scroll", scrollListener);
completeListener = new Object;
completeListener.complete = function() {
trace("logo.swf has completed loading.");
}
myScrollPane.addEventListener("complete", completeListener);
The first block of code is a scroll event handler on the
myScrollPane instance that displays the value of the vPosition
property in a TextField instance called txtPosition. The second
block of code creates an event handler for the complete event
that sends a message to the Output panel.
Related Topics
Popup
Popup
Comments
Add Comment
rustedmud636 said on Nov 8, 2004 at 9:43 PM :
Just wanted to give everyone at Macromedia 2 thumbs up for
all the work accomplished with the MX 2004 Products. You people
and your products are awesome.
Jason
No screen name said on Feb 25, 2005 at 5:49 PM :
In the Actions panel for what object? The Frame? The ScrollPanel?
The latter gives me errors, neither seems to work.
jepo said on Jun 6, 2005 at 7:33 PM :
Thank you for your comments. This site is for documentation
feedback only. Some comments with general questions about
how to use components, bug reports, or feature requests for
the Flash product, have been removed. Please use the Flash
webforums for questions about how to use components: http://webforums.macromedia.com/flash.
Please use this form for feature requests or suspected bugs:
www.macromedia.com/support/email/wishform/.
jepo said on Jun 6, 2005 at 7:35 PM :
no screen name Feb 25:
The code goes on frame 1 of the main Timeline, not on the
scrollpane itself. Generally (for anything) you can tell that
code with on(something)... is placed on the instance. If it
isn't that, put it on the main timeline.
tglennon said on Jul 15, 2005 at 7:08 AM :
When I attempt to use the scroll pane component within a Slide
Presentation template, it displays the .swf, but not at the
same position of the scroll pane; it does not auto detect
the scroll bars, but if you set the scrollpolicy to ON, the
bars appears (without the arrow buttons), it does not function,
you cannot drag it, and the graphic extents outside of the
scroll bar boundaries. I can get this feature to work very
easily in a blank flash document, so I'm wondering if there
are conflicting issues with the Slide Presentation. Any ideas?
|