ActionScript 2.0 Components Language Reference |
|
|
|
| ScrollPane component > Using the ScrollPane component > 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 picture from a path specified by the contentPath property.
To create an application with the ScrollPane component:
/**
Requires:
- ScrollPane in library
*/
System.security.allowDomain("http://www.helpexamples.com");
this.createClassObject(mx.containers.ScrollPane, "my_sp", 10);
my_sp.setSize(320, 240);
// Create listener object for scroll vertical position.
var scrollListener:Object = new Object();
scrollListener.scroll = function(evt_obj:Object) {
trace("hPosition: " + my_sp.hPosition + ", vPosition = " + my_sp.vPosition);
};
// Add listener.
my_sp.addEventListener("scroll", scrollListener);
// Create listener object for completed loading.
var completeListener:Object = new Object();
completeListener.complete = function(evt_obj:Object) {
trace(evt_obj.target.contentPath + " has completed loading.");
};
// Add listener.
my_sp.addEventListener("complete", completeListener);
my_sp.contentPath = "http://www.helpexamples.com/flash/images/image1.jpg";
The examples creates a scroll pane, sets its size, and loads an image to it using the contentPath property. It also creates two listeners. The first one listens for a scroll event and displays the image's position as the user scrolls vertically or horizontally. The second one listens for a complete event and displays a message in the Output panel that says the image has completed loading.
|
|
|
|