Note that there are some explanatory texts on larger screens.

plurals
  1. POAS3/Flash, How to make a button to browse and load dynamic text files within this code?
    primarykey
    data
    text
    <p>This is a script that loads the specified .log (text) file and shows its content dynamically in the movie (artist and song from the current track played). </p> <p>Because the player makes new .log files after a certain time, I need to select the latest .log file manually when starting the .swf or when it changes during the session. What I am doing, is opening the <strong>trackLogNum.txt</strong> file and writing there the 5 NUMBER section (logNum variable) of the .log filename structure, which is, i.e. <em>127.0.0.1,12345.log</em></p> <p>Is there any way to implement a button in this code to browse the .log files in the directory and then select and load the latest one, instead of writing each time the filename in the external <strong>trackLogNum.txt</strong>?</p> <p><em>I think it would be perfect a function that loads automatically the newest .log file (as I see in dynamically loading of pictures within slideshows, which frequently have breadcrumb buttons to go to the first and also the last item), but they said it is not possible without using PHP or Flex. As you notice in the code, it is a local application, no server is running.</em></p> <p>Thank you in advance for your help.</p> <pre><code>var reload:Timer = new Timer(5000, 1); reload.addEventListener(TimerEvent.TIMER, onTimer); //-------------------- var logNumLoader:URLLoader = new URLLoader(); logNumLoader.dataFormat=URLLoaderDataFormat.VARIABLES; logNumLoader.addEventListener(Event.COMPLETE, loadedLogNum); logNumLoader.load(new URLRequest("trackLogNum.txt")); var _logNum:String; function loadedLogNum(e:Event):void { trace(e.target.data.logNum); _logNum = e.target.data.logNum; loadTracks(); } //-------------------- 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("127.0.0.1,"+_logNum+".log")); } function parseTracks(data:String):void { try { var lines:Array = data.split("\n"); var lastLine:String = lines[lines.length - 2]; var artistAndSong:String = lastLine.substr(24).split(" - ").join("\n\n-&gt;"); trace(artistAndSong); track_info.text = artistAndSong; addChild(track_info); } catch(e:Error) { } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload