I am trying to load folder names into an array for later use. It works fine on my desktop but when I test it on a mobile device (both Android and iPhone) and it is calling another function - displayFlags(); - before I get the folder names into an array.
displayFlags() needs this array of names to work and I am getting errors from this line in of code in displayFlags(); Again its because the array is empty.
flag.load(new URLRequest(LangPath[i] + "/flag.png"));
Below is the code that loads file and the array. Is there a way to check when the array is available and call a function after its loaded?
var folderLanguages:File = File.applicationDirectory.resolvePath("Languages");
var availLang:Array = folderLanguages.getDirectoryListing();
var Lang:Array;
var LangPath:Array;
var flagButton:MovieClip;
function getLang(evt:Event = null)
{
Lang = new Array();
LangPath = new Array();
for (var i:uint = 0; i < availLang.length; i++)
{
if(availLang[i].isDirectory)
{
//trace(availLang[i].name);// gets the name
Lang.push(availLang[i].name);
LangPath.push(availLang[i].nativePath);
trace(availLang[i].nativePath);// gets the name
}
}
displayFlags();
}