If you have a large amount of content in some Flex Group object (or HGroup, VGroup, etc.), you may need to scroll the content.  Adding a Scroller in MXML is pretty simple and there are a lot of docs for it.

However, if you are generating a large-sized Group, and want to use a NavigatorContainer in Actionscript (not MXML), you cannot simply do:

var group:Group = new Group();
var scroller:Scroller = new Scroller();
scroller.addElement(group);

You have to set the Scroller’s viewport to your group, like this:

accordianScroller.viewport = accordianGroup;

Further, you do not add your Group to the NavigatorContent.  Instead, you add the Scroller to your NavigatorContent; this will also add the attached Group as well.

Below is a more complete example.  Though it is specifically related to the Accordian control, this setting a scrollbar will follow the same process for all NavigatorContent and Group objects.  It was only in the example of Adobe’s docs for IViewport that I finally figured out how to do this:

// Create content area to add to the Accordian object (defined in MXML, in this case).
var accordianItem:NavigatorContent = new NavigatorContent();

// Create a group, and add items to it here. . .
var accordianGroup:Group = [...] 

if(accordianGroup)
{
    // Create the scrollbar control, one for each NavigatorContent object.
    var accordianScroller:Scroller = new Scroller();
    accordianScroller.percentWidth = accordianScroller.percentHeight = 100;

    // Add a scrollbar to the group.
    // NOTE: It took a long time for me to find out how to do this.
    accordianScroller.viewport = accordianGroup;

    // Add the scrollbar to the content.  This will intrinctically add the group.
    accordianItem.addElement(accordianScroller);

    // Some more sizing stuff.
    accordianItem.percentWidth = accordianItem.percentHeight = 100;
}

// Add the content as a new Accordian button.
yourAccordianObject.addElement(accordianItem);

– 30 –

Advertisements