Class com.maheshj.UI.ScrollBox

Description

This is a scroller class into which you can load jpg, png, gif or swf's. You can scroll the content both horizontally and vertically. The class will take care of all the resizing for you and all you have to do is initialize it with the desired scrolling dimensions. You may change them later as well. The following events are dispatched by this class:

ScrollPaneResized - This event is fired when the scroller is resized from the outside (maybe due to a stage resize listener). The event object has the following properties:
width - A number denoting the width of the displayed content.
height - A number denoting the height of the displayed content.
You can listen to this event to know when the scrollbox is resized. The scrollbox has a movieclip with name content_mc into which all the dynamic content will be loaded. This movieclip is registered with the event by default when the scrollbox is initialized.

ConLoadStarted - Same as onLoadStart event of MovieClipLoader class. Fired when content starts loading after loadContent function is called.

ConLoading - Same as onLoadProgress event of MovieClipLoader class. Fired when content progresses loading after loadContent function is called. The event object has an object names loadProgress which has two properties bytesLoaded and bytesTotal which can be used to track the progress of the loading.

ConLoadInit - Same as onLoadInit event of MovieClipLoader class. Fired when content initializes loading after loadContent function is called.

ConLoadComplete - Same as onLoadComplete event of MovieClipLoader class. Fired when content completes loading after loadContent function is called.

ConLoadError - Same as onLoadError event of MovieClipLoader class. Fired when error occurs while loading content after loadContent function is called.

Usage: Since this class extends MovieClip class, you must attach it to a movieclip that you want to behave as a scrollbox. For this class to function properly, you need to have mask_mc movieclip that will mask the content to be scrolled, two scrollbars, hscroll_mc and vscroll_mc which must be instances of ScrollBar class. See the documentation of ScrollBar class to see how to make a movieclip that can behave as a scrollbar. First make a vertical scrollbar and put it in the scroller movieclip. Then duplicate it in the library. Give it a different name. Put it inside the scroller movieclip and rotate it counter-clockwise 90 degress to make a horizontal scrollbar. Then flip it vertically to bring its registration point to the top-left. You also need to have a movieclip named content_mc. The content will be loaded into this movieclip. All this movieclips must be placed inside the movieclip to which you will attach this class. To attach this class to a movieclip, in the library, right-click on the movieclip that you want to use as scrollbox, and select Linkage. In the Class: field, write com.maheshj.UI.scroller.ScrollBox and click OK. Make sure that the com directory in which the scrollbar classes are provided are available in the FLA's classpaths.

Field Index

content_mc, keyBoardScrollEnabled, keyBoardSpeed, mouseScrollEnabled, mouseWheelSpeed, scaleScrollBars, scrollDelay, scrollEaseType, scrollsHorizontally, scrollsVertically, scrollTime

Method Index

addEventListener(), init(), loadContent(), removeEventListener(), resize()

Field Detail

content_mc

public content_mc:MovieClip

scrollsHorizontally

public scrollsHorizontally:Boolean
Use this property to get or set whether the scrollbox will scroll horizontally or not. The valid values are true or false

scrollsVertically

public scrollsVertically:Boolean
Use this property to get or set whether the scrollbox will scroll vertically or not. The valid values are true or false

scaleScrollBars

public scaleScrollBars:Boolean
Use this property to get or set whether the faces of the scrollbars scale according to the content dimensions or not. The valid values are true or false

mouseScrollEnabled

public mouseScrollEnabled:Boolean
Use this property to enable or disable mousewheel scroll for the scrollbox. Valid values are true and false

keyBoardScrollEnabled

public keyBoardScrollEnabled:Boolean
Use this property to enable or disable keyboard scroll for the scroller. Valid values are true and false

mouseWheelSpeed

public mouseWheelSpeed
Use this property to get or set the extent of scrolling that happens with the mouse wheel. Default value is 5. You can use any number greater than zero.

keyBoardSpeed

public keyBoardSpeed:Number
Use this property to get or set the extent of scrolling that happens with the keyboard. Default value is 15. You can use any number greater than zero.

scrollDelay

public scrollDelay
Use this property to get and set the delay in scrolling. Default value is 0.

scrollTime

public scrollTime
Use this property to get and set the time for the scrolling to happen. Default value is 0.5.

scrollEaseType

public scrollEaseType
Use this property to get and set the easing type for the scrolling animation. Default value is easeOutQuad. But you can use all the easeing types offered by Tweener.

Method Detail

init

public function init(hScrollHeight:Number, vScrollHeight:Number, hScroll:Boolean, vScroll:Boolean, mouse:Boolean, keyboard:Boolean, scaleBars:Boolean)

This method is used to initialize the scrollbox with the desired properties as listed below. All these parameters are except hScrollHeight and vScrollHeight are optional. If others parameters are not specified in the function call, they are initialized to false

Parameters

hScrollHeight- Number representing the height of the horizontal scrollbar as well as its scrollheight
vScrollHeight- Number representing the height of the vertical scrollbar as well as its scrollheight
hScroll- [Optional] A boolean value to specify whether horizontal scrolling is enabled or not.
vScroll- [Optional] A boolean value to specify whether vertical scrolling is enabled or not.
mouse- [Optional] A boolean value to specify whether mouse wheel scrolling is enabled or not.
keyboard- [Optional]A boolean value to specify whether scrolling with keyboard is enabled or not.
scaleBars- [Optional] A boolean value to specify whether the faces of the scrollbar will be scaled according to the content dimensions.

loadContent

public function loadContent(path:String)

If the ScrollBox is used to load content dynamically into it at runtime, then the content can be loaded with this method.

Parameters

path- The path of the file to be loaded into content_mc movieclip.

resize

public function resize(width:Number, height:Number)

If you want to resize the scrollbox at runtime after setting up the scroll width and height initially, you can use this method.

Parameters

width- [Optional] The width to which it is to be resized.
height- [Optional] The height to which it is to be resized.

addEventListener

public function addEventListener()

removeEventListener

public function removeEventListener()