Revision: 30837
Updated Code
at August 23, 2010 20:26 by adrianparr
Updated Code
package { import flash.display.MovieClip; import flash.events.Event; import flash.events.IOErrorEvent; import flash.net.URLLoader; import flash.net.URLRequest; public class Main extends MovieClip { private var _txtFileToLoad:String = "myTextFile.txt"; private var _txtLoader:URLLoader; private var _loadedTxt:String; public function Main():void { loadExternalTxtFile(); } private function loadExternalTxtFile():void { _txtLoader = new URLLoader(); _txtLoader.addEventListener(Event.COMPLETE, onTxtLoader_COMPLETE); _txtLoader.addEventListener(IOErrorEvent.IO_ERROR, onTxtLoader_IO_ERROR); _txtLoader.load(new URLRequest(_txtFileToLoad)); } private function onTxtLoader_COMPLETE(event:Event):void { _txtLoader.removeEventListener(Event.COMPLETE, onTxtLoader_COMPLETE); _txtLoader.removeEventListener(IOErrorEvent.IO_ERROR, onTxtLoader_IO_ERROR); _loadedTxt = String(event.target.data); trace(_loadedTxt); } private function onTxtLoader_IO_ERROR(event:Event):void { _txtLoader.removeEventListener(Event.COMPLETE, onTxtLoader_COMPLETE); _txtLoader.removeEventListener(IOErrorEvent.IO_ERROR, onTxtLoader_IO_ERROR); trace(event.target.text); } } }
Revision: 30836
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at August 23, 2010 20:24 by adrianparr
Initial Code
package { import flash.display.MovieClip; import flash.events.Event; import flash.events.IOErrorEvent; import flash.net.URLLoader; import flash.net.URLRequest; public class Main extends MovieClip { private var _txtLoader:URLLoader; private var _loadedTxt:String; public function Main():void { loadExternalTxtFile(); } private function loadExternalTxtFile():void { _txtLoader = new URLLoader(); _txtLoader.addEventListener(Event.COMPLETE, onTxtLoader_COMPLETE); _txtLoader.addEventListener(IOErrorEvent.IO_ERROR, onTxtLoader_IO_ERROR); _txtLoader.load(new URLRequest("lang.txt")); } private function onTxtLoader_COMPLETE(event:Event):void { _txtLoader.removeEventListener(Event.COMPLETE, onTxtLoader_COMPLETE); _txtLoader.removeEventListener(IOErrorEvent.IO_ERROR, onTxtLoader_IO_ERROR); _loadedTxt = String(event.target.data); trace(_loadedTxt); } private function onTxtLoader_IO_ERROR(event:Event):void { _txtLoader.removeEventListener(Event.COMPLETE, onTxtLoader_COMPLETE); _txtLoader.removeEventListener(IOErrorEvent.IO_ERROR, onTxtLoader_IO_ERROR); trace(event.target.text); } } }
Initial URL
Initial Description
Initial Title
AS3 Load External Text File
Initial Tags
file, text, load
Initial Language
ActionScript 3