Hi Guys Thanks for your help in advance!!
I'm trying to dynamically load views. The view Names are stored in a xml file and i would like to be able to pass the name into the pushView() method so that I can load different views depending on what the user selects from the list.
Appreciate your help guys :-)
Here is what I have.
Code:
<fx:Script>
<![CDATA[
import flash.utils.getDefinitionByName;
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
import spark.events.IndexChangeEvent;
import spark.transitions.SlideViewTransition;
import spark.transitions.SlideViewTransitionMode;
import spark.transitions.ViewTransitionDirection;
[Bindable]
protected var myXml:ArrayCollection;
protected function getXmlData_resultHandler(event:ResultEvent):void
{
myXml = event.result.xmldata.section;
}
protected function mainList_changeHandler(event:IndexChangeEvent):void
{
//trace(mainList.selectedItem.sectionName);
var viewName:Class = mainList.selectedItem.sectionName;
var slideTrans:SlideViewTransition = new SlideViewTransition();
slideTrans.direction = ViewTransitionDirection.LEFT;
slideTrans.mode = SlideViewTransitionMode.UNCOVER;* //or COVER and PUSH modes
slideTrans.duration = 500;
navigator.pushView(viewName, mainList.selectedItem, null, slideTrans);
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<s:HTTPService url="xml/xmldata.xml" id="getXmlData" result="getXmlData_resultHandler(event)"/>
</fx:Declarations>
<s:Image left="0" top="0" width="100%" height="300" smooth="true"
smoothingQuality="default" source="images/feature.jpg" fillMode="clip"/>
<s:List id="mainList" dataProvider="{myXml}" change="mainList_changeHandler(event)" left="0" right="0" top="299" bottom="0" labelField="sectionTitle">
<s:itemRenderer>
<fx:Component>
<s:IconItemRenderer iconFunction="getIconURL" iconWidth="100" iconHeight="100" height="110" verticalAlign="top">
<fx:Script>
<![CDATA[
protected function getIconURL(item:Object):String{
return "icons/" + item.sectionIcon;
}
]]>
</fx:Script>