Hi,
I have an external log file which name changes each session, with the format XXXXX.log
I need to load it inside a swf to show its data, but each time the log´s name is different, I need to open the .fla, changing the name of the file and then republishing the swf.
So I have made a simple script to load another .txt, to type manually in it the 5 number of the log´s name and load it externally inside the swf:
var logNumLoader:URLLoader = new URLLoader();
logNumLoader.dataFormat=URLLoaderDataFormat.VARIABLES;
logNumLoader.addEventListener(Event.COMPLETE, loadedLogNum);
logNumLoader.load(new URLRequest("infoLogNum.txt"));
function loadedLogNum(e:Event):void {
trace(e.target.data.logNum); // HOW TO GET THE VALUE OF logNum... *(see below)
}
The "infoLogNum.txt" contains just a variable, which is the manually typed name of the .log, like:
logNum=12345
This script works perfect, as it outputs the variable value, in this case "12345".
But I need this "logNum" value to be passed inside another function that loads and opens the XXXXX.log (see in the code at the bottom):
...
var tracksLoader:URLLoader = new URLLoader();
tracksLoader.addEventListener(Event.COMPLETE,onTracksLoaded);
tracksLoader.addEventListener(IOErrorEvent.IO_ERROR,onTracksError);
tracksLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR,onTracksError);
loadTracks();
function onTracksLoaded(e:Event):void {
trace("onTracksLoaded");
parseTracks(tracksLoader.data);
reload.start();
}
function onTimer(event:TimerEvent):void{
loadTracks();
}
function onTracksError(e:Event):void {
trace("onTracksError", e);
reload.start();
}
function loadTracks():void {
tracksLoader.load(new URLRequest(logNum+".log")); // (*) ...AND SET THE logNum VALUE HERE
}
While I cannot assign the value of logNum to the last function, the .log cannot be opened.
I have no clue on how to make it work. Any ideas, please?
TIA.