Hello,
This is an example of how to select a ViewStack child continer from a
menuEvent. This function is called in the itemClick event of the
MenuBar and the MenuBar is populated with a dataProvider such as this:
[Bindable]
public var header_menu_array1:Array = [{label: "MenuItem A", children: [
{label: "SubMenuItem A-1", enabled: true, click: "sm_main"},
{label: "", type: "separator"},
{label: "SubMenuItem A-2", type: "normal", click: "sm_man2"}
]}
];
Note that the "click" attribute is used in the function below
(event.item.click) to designate the id of the container under the
ViewStack you wish to switch to. In the below function you pass in
the viewstack as well (theVS). Type casting the getChildAt(i) as
Container was the key making this work and can be used for many other
things. Enjoy!
// function to switch the view stack when a menu selection is selected
private function skinMenuHandler(event:MenuEvent,theVS:ViewStack):void {
if(event.item.click != null) {
var theSelectedItem:String = event.item.click;
for(var i:int; i < theVS.getChildren().length; i++) {
// trace(childrenVBox.getChildAt(i).id);
var currentChildComponent:Container =
theVS.getChildAt(i) as Container;
if(currentChildComponent.id == theSelectedItem) {
theViewStack.selectedChild=currentChildComponent;
}
}
}
}
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/