Packageflexlib.controls
Classpublic class ScrollableMenu
InheritanceScrollableMenu Inheritance mx.controls.Menu
SubclassesScrollableArrowMenu

An extension of mx.controls.Menu that allows the control to scroll vertically.

Overrides a few methods and properties so we can re-enable scrolling. The Menu control in the Flex framework intentionally disables vertical scrolling. This class simply undoes alot of that. We reinstitute normal verticalScrollPolicy functionality.

See also

mx.controls.Menu


Public Properties
 PropertyDefined by
  verticalScrollPolicy : String
Override the verticalScrollPolicy so we can re-instate scrolling functionality.
ScrollableMenu
Public Methods
 MethodDefined by
  
Constructor
ScrollableMenu
  
createMenu(parent:DisplayObjectContainer, mdp:Object, showRoot:Boolean = true):ScrollableMenu
[static] We have to override the static function createMenu so that we create a ScrollableMenu instead of a normal Menu.
ScrollableMenu
  
move(x:Number, y:Number):void
ScrollableMenu
  
show(xShow:Object = null, yShow:Object = null):void
ScrollableMenu
Protected Methods
 MethodDefined by
  
Overridden to reinstate proper scrolling functionality.
ScrollableMenu
  
ScrollableMenu
  
measure():void
We overide the measure() method because we need to check if the menu is going off the stage.
ScrollableMenu
Property detail
verticalScrollPolicyproperty
verticalScrollPolicy:String  [read-write]

Override the verticalScrollPolicy so we can re-instate scrolling functionality.

The mx.controls.Menu class overrides setting and getting the verticalScrollPolicy Basically setting the verticalScrollPolicy did nothing, and getting it always returned ScrollPolicy.OFF. So that's not going to work if we want the menu to scroll. Here we reinstate the verticalScrollPolicy setter, and keep a local copy of the value in a private variable _verticalScrollPolicy.

Implementation
    public function get verticalScrollPolicy():String
    public function set verticalScrollPolicy(value:String):void
Constructor detail
ScrollableMenu()constructor
public function ScrollableMenu()

Constructor

Method detail
configureScrollBars()method
protected override function configureScrollBars():void

Overridden to reinstate proper scrolling functionality.

The Menu class overrode configureScrollBars() and made the function do nothing. That means the scrollbars don't know how to draw themselves, so here we reinstate configureScrollBars. This is basically a copy of the same method from the mx.controls.List class. It would have been nice if we could have called this method from down in a subclass of Menu, but AS doesn't let us do something like super.super, so instead we have to recreate the class here.

createMenu()method 
public static function createMenu(parent:DisplayObjectContainer, mdp:Object, showRoot:Boolean = true):ScrollableMenu

We have to override the static function createMenu so that we create a ScrollableMenu instead of a normal Menu.

Parameters
parent:DisplayObjectContainer
 
mdp:Object
 
showRoot:Boolean (default = true)

Returns
ScrollableMenu
createSubMenu()method 
protected function createSubMenu():Menu

Returns
Menu
measure()method 
protected override function measure():void

We overide the measure() method because we need to check if the menu is going off the stage. If it's going to be too high, then we make it smaller to keep it from going off. I also stuck in a buffer of 10 pixels from the bottom of the stage. We also check if we're showing the vertical scrollbar, and if so we adjust the width to account for that.

move()method 
public override function move(x:Number, y:Number):voidParameters
x:Number
 
y:Number
show()method 
public override function show(xShow:Object = null, yShow:Object = null):voidParameters
xShow:Object (default = null)
 
yShow:Object (default = null)