| Package | qnx.ui.listClasses |
| Class | public class ScrollPane |
| Inheritance | ScrollPane UIComponent flash.display.MovieClip |
ScrollPane class represents a scrolling pane. The ScrollPane is useful for
displaying large amounts of data such as text, large images, or maps. The user can drag the scoll pane to view the data
that is currently outside of the viewport.
See also
| Property | Defined By | ||
|---|---|---|---|
![]() | containment : String
Gets or sets a property that determines how a component is contained within a parent container. | UIComponent | |
| enableShadows : Boolean
Enables or disables scroll shadows. | ScrollPane | ||
| scrollBarAlpha : Number
Gets or sets the opacity value for the scroll bar on the list. | ScrollPane | ||
| scrollBarColor : Number
Gets or sets the color of the scroll bar. | ScrollPane | ||
| scrollBarOffset : int
Gets or sets the x or y postion of the scrollbar, in pixels. | ScrollPane | ||
| scrollDirection : String
Sets a String representing the scroll direction of the scroll pane. | ScrollPane | ||
| scrollX : int
Sets the x position of the content item given a pixel value. | ScrollPane | ||
| scrollY : int
Sets the y position of the content item given a pixel value. | ScrollPane | ||
![]() | size : Number
Gets or sets the size for this component (as a percentage of the
container's size, or in pixels). | UIComponent | |
![]() | sizeMode : String
Gets or sets the size mode for this component. | UIComponent | |
![]() | sizeUnit : String
Gets or sets the unit of measure for the size property. | UIComponent | |
| Method | Defined By | ||
|---|---|---|---|
Creates a ScrollPane instance. | ScrollPane | ||
![]() | destroy():void
Call this method when you want to have your object collected by the garbage collector. | UIComponent | |
![]() | drawNow():void
Calls the draw() method. | UIComponent | |
getScrollContent():DisplayObject
Returns the ScrollPane content as a DisplayObject. | ScrollPane | ||
![]() | invalidate(property:String, invalidateNow:Boolean = false):void
Marks the property as invalid and the draw() method is called on the next frame or the next render, whichever comes first. | UIComponent | |
removeScrollContent():DisplayObject
Removes all content from the ScrollPane instance. | ScrollPane | ||
![]() | setPosition(x:Number, y:Number):void
Sets the x and y position of the component. | UIComponent | |
setScrollContent(content:Object):DisplayObject
Sets content for the ScrollPane instance. | ScrollPane | ||
![]() | setSize(w:Number, h:Number):void
Sets the width and height of the component. | UIComponent | |
update():void
Refreshes the scroll pane properties based on the width and height of the content. | ScrollPane | ||
| Event | Summary | Defined By | ||
|---|---|---|---|---|
| Dispatched when scrolling begins. | ScrollPane | |||
| Dispatched when scrolling ends. | ScrollPane | |||
| Dispatched when scrolling occurs. | ScrollPane | |||
| enableShadows | property |
enableShadows:Boolean
Enables or disables scroll shadows. The scroll shadows are vertical and horizontal bars that appear on the edge of the
ScrollPane instance. They provide context as to the extent of the content within the ScrollPane.
The default value is true.
public function get enableShadows():Boolean public function set enableShadows(value:Boolean):void| scrollBarAlpha | property |
scrollBarAlpha:NumberGets or sets the opacity value for the scroll bar on the list.
When the list is pressed it reveals the scroll bar. The scroll bar alpha determines the opacity of the scroll bar when it is revealed.
The default value is 0.5.
public function get scrollBarAlpha():Number public function set scrollBarAlpha(value:Number):void| scrollBarColor | property |
scrollBarColor:NumberGets or sets the color of the scroll bar.
The default value is 0x737a80.
public function get scrollBarColor():Number public function set scrollBarColor(value:Number):voidSee also
| scrollBarOffset | property |
scrollBarOffset:intGets or sets the x or y postion of the scrollbar, in pixels.
The offset value is relative to the scrollDirection property and is used to position the scrollbar relative to the edge of the pane. For
example, when the scrollpane scrolls vertically, the offset value is relative to the right edge of the pane, since the scroll bar appears on the right side of
the scroll pane.
The default value is 10.
public function get scrollBarOffset():int public function set scrollBarOffset(value:int):voidSee also
| scrollDirection | property |
scrollDirection:String
Sets a String representing the scroll direction of the scroll pane.
The direction argument can be NONE (unable to scroll), BOTH (can scroll in both directions if content exceeds pane
height or width), HORIZONTAL (can only scroll horizontally) and VERTICAL (only on the vertical).
public function get scrollDirection():String public function set scrollDirection(value:String):voidSee also
| scrollX | property |
scrollX:intSets the x position of the content item given a pixel value.
The minimum value is 0 pixels, and the maximum value is equal to the width of the content item.
public function get scrollX():int public function set scrollX(value:int):void| scrollY | property |
scrollY:intSets the y position of the content item given a pixel value.
The minimum value is 0 pixels, and the maximum value is equal to the height of the content item.
public function get scrollY():int public function set scrollY(value:int):void| ScrollPane | () | Constructor |
public function ScrollPane()
Creates a ScrollPane instance.
| getScrollContent | () | method |
public function getScrollContent():DisplayObject
Returns the ScrollPane content as a DisplayObject.
DisplayObject — A DisplayObject containing the scroll pane content.
|
| removeScrollContent | () | method |
public function removeScrollContent():DisplayObject
Removes all content from the ScrollPane instance.
DisplayObject — DisplayObject
|
| setScrollContent | () | method |
public function setScrollContent(content:Object):DisplayObject
Sets content for the ScrollPane instance.
You can set an item to the scroll pane by passing either a class reference, a String linkage identifier,
or an instance of a DisplayObject.
Parameters
content:Object — The content to be added to the ScrollPane.
|
DisplayObject — Returns the item that was added.
|
| update | () | method |
public function update():voidRefreshes the scroll pane properties based on the width and height of the content.
Call this function if the content of the ScrollPane changes during run time.
| scrollBegin | Event |
qnx.ui.events.ScrollEventqnx.ui.events.ScrollEvent.SCROLL_BEGINDispatched when scrolling begins.
| scrollEnded | Event |
qnx.ui.events.ScrollEventqnx.ui.events.ScrollEvent.SCROLL_ENDDispatched when scrolling ends.
| scrollMove | Event |
qnx.ui.events.ScrollEventqnx.ui.events.ScrollEvent.SCROLL_MOVEDispatched when scrolling occurs.
The following example provides a ScrollPane that is used to view a large image. The image is included in the assets folder.
package
{
import flash.display.Sprite;
import qnx.ui.data.DataProvider;
import qnx.ui.events.ScrollEvent;
import qnx.ui.listClasses.ScrollPane;
import qnx.ui.listClasses.ScrollDirection;
import qnx.ui.text.Label;
[SWF(height="600", width="1024", frameRate="30", backgroundColor="#FFFFFF")]
public class listSample extends Sprite
{
private var myScrollPane:ScrollPane;
private var myLabel:Label;
[Embed(source="../assets/pup.jpg")]
public static var bigImage:Class;
public function listSample()
{
initializeUI();
}
private function initializeUI():void
{
myScrollPane = new ScrollPane();
myScrollPane.setPosition(50, 50);
myScrollPane.width = 300;
myScrollPane.height = 300;
myScrollPane.scrollDirection = ScrollDirection.BOTH;
myScrollPane.setScrollContent( bigImage );
myScrollPane.addEventListener(ScrollEvent.SCROLL_END, onScroll);
myScrollPane.addEventListener(ScrollEvent.SCROLL_BEGIN, onScrollStart);
this.addChild(myScrollPane);
}
private function onScroll(event:ScrollEvent):void {
trace("Finished scrolling...");
}
private function onScrollStart(event:ScrollEvent):void {
trace("Start scrolling...");
}
}
}
The following example provides a ScrollPane that is used to view a large paragraph of text.
package
{
import flash.display.Sprite;
import qnx.ui.events.ScrollEvent;
import qnx.ui.listClasses.ScrollPane;
import qnx.ui.listClasses.ScrollDirection;
import qnx.ui.text.Label;
[SWF(height="600", width="1024", frameRate="30", backgroundColor="#FFFFFF")]
public class listSample extends Sprite
{
private var myScrollPane:ScrollPane;
private var myLabel:Label;
public function listSample()
{
initializeUI();
}
private function initializeUI():void
{
myScrollPane = new ScrollPane();
myScrollPane.setPosition(100, 100);
myScrollPane.width = 400;
myScrollPane.height = 300;
myScrollPane.scrollDirection = ScrollDirection.BOTH;
var myLabel:Label = new Label();
myLabel.multiline = true;
myLabel.width = 600;
myLabel.height = 600;
myLabel.textField.wordWrap = true;
myLabel.multiline = true;
myLabel.text = "Lorem ipsum dolor sit amet, consectetur adipiscing " +
"elit. Sed convallis facilisis massa. Sed porttitor, velit nec eleifend " +
"tincidunt, eros velit imperdiet magna, sed fermentum libero nulla et mauris." +
" Sed pellentesque, lectus vel sagittis interdum, nisi lectus lobortis tortor," +
" in consequat augue metus non justo. Vivamus ut magna in risus mattis commodo. " +
"Integer lacinia pharetra sodales. Morbi ornare, sem vitae vestibulum condimentum," +
" ipsum mi condimentum neque, at imperdiet eros lectus nec eros. Morbi aliquam " +
"convallis mauris, vel suscipit elit lacinia non. Donec id porttitor eros. " +
"Quisque accumsan dui in eros porta aliquet condimentum eros pellentesque. " +
"Fusce blandit nisl facilisis justo hendrerit vitae blandit ante elementum. " +
"Cras nisl massa, ornare sed hendrerit non, cursus at eros. Nulla facilisi. ";
this.addChild(myLabel);
myScrollPane.setScrollContent( myLabel );
myScrollPane.addEventListener(ScrollEvent.SCROLL_END, onScroll);
myScrollPane.addEventListener(ScrollEvent.SCROLL_BEGIN, onScrollStart);
this.addChild(myScrollPane);
}
private function onScroll(event:ScrollEvent):void {
trace("Finished scrolling...");
}
private function onScrollStart(event:ScrollEvent):void {
trace("Start scrolling...");
}
}
}