Is it possible to use a global variable defined in app.mxml within the myIconFunction defined below ?
<s:List id="list" x="7" y="10" width="463" height="661"
creationComplete="list_creationCompleteHandler(event)" labelField="name" click="list_clickHandler(event)">
<s:itemRenderer>
<fx:Component>
<s:IconItemRenderer labelField="name"
iconFunction="myIconFunction"
decorator="@Embed(source='assets/images/general/arrow_next.jpg')"
iconWidth="50"
iconHeight="50">
<fx:Script>
<![CDATA[
private function myIconFunction(item:Object):String
{
return "http://localhost/mydatapath/" + item.imagelink;
// how to use this.parentApplication.dataPath here
}
]]>
</fx:Script>
</s:IconItemRenderer>
</fx:Component>
</s:itemRenderer>
</s:List>
The parentApplication.dataPath variable stores IP of my server. Since I have used similar functions at several places in my application, it requires me to change the IP at every place when I move from localhost to actual server.
Using
this.parentApplication.dataPath + item.imagelink
gives compile time error.
So is it possible to use an external/global variable within such a function ?
I solved the problem by making the myIconFunction public