I have this function th开发者_StackOverflow社区at loads an specific .log file:
function loadTracks():void {
tracksLoader.load(new URLRequest("/Users/Me/127.0.0.1,"+_logNum+".log"));
}
The logNum variable gets its value, writing it by hand in a separate text file, avoiding to open and editing the .fla each time the new .log has a different name:
logNumLoader.load(new URLRequest("/Users/Me/trackLogNum.txt"));
So this is my question:
Some application creates in each session a new .log file with this file name pattern:
127.0.0.1,NUMBER.log // Being NUMBER the 5 digit changing part of the name, each time a new .log file is created. The newer the file, the higher this value is.
I would like to know how to make this script to autoload the last .log file, as it has the highest value in its name.
I.E.
Having in /Users/ME/
127.0.0.1,12345.log
127.0.0.1,34567.log
127.0.0.1,56789.log
In this case, the script must automatically select and load the 127.0.0.1,56789.log file.
Thank you in advance.
I would use PHP to either identify the latest log by using the filemtime function or by sorting the log files ( following your description , the highest log should come last ).
Edit:
This can't be done in Actionscript 3, unless it's an Air application. AS3 deals with the client site and accessing files & directories is a server side operation.
I'm not a PHP guru so , although I could offer a solution that works fine, it would take me more time and might not be as efficient as what some of the PHP stars here could come up with. I would recommend you to either retag your question or simply post a new question asking what script you actually need to sort out your log files.
When you have the PHP script, look at the following tutorial to see how you can load PHP result into your Flash application. In this example , the script retrieves value from a database, but you should be able to easily adapt this to your context , as long as the script returns content in the form of a name/value pair. It's all explained in the tutorial ;)
http://www.flash-db.com/Tutorials/loadingAS3/loadingData.php?page=5
精彩评论