[Flashcoders] getting text from textfile.txt into a dynamic text field
In CS4 (AS3) I have a simple text file for my client to easily update their text content. I found the method var loader:URLLoader = new URLLoader(new URLRequest(textfile1.txt)); that is supposed to load data from the external text file, but I can't work out what I need to do to then get that text into a dynamic text field. Can anyone please give me a simple example of how to do this. Alan Neilsen This message is for the named persons use only. It may contain confidential, proprietary or legally privileged information. No confidentiality or privilege is waived or; lost by any mistransmission. If you receive this message in error, please immediately delete it and all copies of it from your system, destroy any hard copies of it and notify the sender. You must not directly or indirectly, use, disclose, distribute, print or copy any part of this message if you are not the intended recipient. GOULBURN OVENS INSTITUTE OF TAFE and any of its subsidiaries each reserve the right to monitor all e-mail communications through its networks. Any views expressed in this message are those of the individual sender, except where the message states otherwise and the sender is authorised to state them to be the views of any such entity. # This e-mail message has been scanned for Viruses and Content and cleared by MailMarshal # ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] getting text from textfile.txt into a dynamic text field
var loader:URLLoader = new URLLoader(); loader.addEventListener(Event.COMPLETE, onLoaded); loader.load(new URLRequest(textfile1.txt)); function onLoaded(e:Event):void { someField_txt.text = e.target.data; } On Mon, Nov 23, 2009 at 4:51 PM, Alan Neilsen aneil...@gotafe.vic.edu.auwrote: In CS4 (AS3) I have a simple text file for my client to easily update their text content. I found the method var loader:URLLoader = new URLLoader(new URLRequest(textfile1.txt)); that is supposed to load data from the external text file, but I can't work out what I need to do to then get that text into a dynamic text field. Can anyone please give me a simple example of how to do this. Alan Neilsen This message is for the named person’s use only. It may contain confidential, proprietary or legally privileged information. No confidentiality or privilege is waived or; lost by any mistransmission. If you receive this message in error, please immediately delete it and all copies of it from your system, destroy any hard copies of it and notify the sender. You must not directly or indirectly, use, disclose, distribute, print or copy any part of this message if you are not the intended recipient. GOULBURN OVENS INSTITUTE OF TAFE and any of its subsidiaries each reserve the right to monitor all e-mail communications through its networks. Any views expressed in this message are those of the individual sender, except where the message states otherwise and the sender is authorised to state them to be the views of any such entity. # This e-mail message has been scanned for Viruses and Content and cleared by MailMarshal # ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- http://ericd.net Interactive design and development ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] getting text from textfile.txt into a dynamic text field
Hi, You need to add an event listener to the loader object to listen for the Complete event which tells you when the file has loaded. Then in this event you grab the data property of the loader object, e.g import flash.events.Event; //... function load():void { var loader:URLLoader = new URLLoader(new URLRequest(textfile1.txt)); loader.addEventListener(Event.COMPLETE, _textLoaded, false, 0, true); } function _textLoaded(e:Event):void { trace(_textLoaded! + e.currentTarget.data); //set as your text field content: myTextField.text = e.currentTarget.data; //could also be myTextField.htmlText } load(); You may also need to look at adding listeners for some of the other things that might happen to your loader - look at the events part of the documentation for errors, etc. http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/URLLoader.html#event:complete HTH Glen Alan Neilsen wrote: In CS4 (AS3) I have a simple text file for my client to easily update their text content. I found the method var loader:URLLoader = new URLLoader(new URLRequest(textfile1.txt)); that is supposed to load data from the external text file, but I can't work out what I need to do to then get that text into a dynamic text field. Can anyone please give me a simple example of how to do this. Alan Neilsen This message is for the named person’s use only. It may contain confidential, proprietary or legally privileged information. No confidentiality or privilege is waived or; lost by any mistransmission. If you receive this message in error, please immediately delete it and all copies of it from your system, destroy any hard copies of it and notify the sender. You must not directly or indirectly, use, disclose, distribute, print or copy any part of this message if you are not the intended recipient. GOULBURN OVENS INSTITUTE OF TAFE and any of its subsidiaries each reserve the right to monitor all e-mail communications through its networks. Any views expressed in this message are those of the individual sender, except where the message states otherwise and the sender is authorised to state them to be the views of any such entity. # This e-mail message has been scanned for Viruses and Content and cleared by MailMarshal # ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- Glen Pike 01326 218440 www.glenpike.co.uk http://www.glenpike.co.uk ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders