Flex 4 Scroller using pure Actionscript

I had to figure out how to use the new Flex 4 scrolling using pure Actionscript over the last day or two. It isn’t obviouse what the set up is right away without seeking out some documentation or posts by other users. 

The MXML version would lead you to believe that you you would just addElement() to a scroller object and you would be good to go.

<s:Scroller left="2" right="2" top="2" bottom="2">
<s:Group id="vp" horizontalScrollPosition="57" verticalScrollPosition="198">
<mx:Image source="http://sites.google.com/site/hansmuller/Home/archive/gyro-original.jpg"/>

Here is an example of adding a scroller to a VGroup in pure AS3.

_vgroup = new VGroup();
_vgroup.gap = 0;

_scroller = new Scroller();
_scroller.percentHeight = 100;
_scroller.viewport = _vgroup;


As you can see you create the component instance that you would like to apply the scroller too. Create the scroller and tell the scroller what component it is going to use for it’s viewport and then you add the scroller to the display list. Doing this takes care of adding the component that you will be scrolling to the view for you. Pretty nice way of doing this but not the most obvious.