Skip to main content
Participant
April 13, 2009
Question

External text/xml into a Dynamic Text Box

  • April 13, 2009
  • 2 replies
  • 2277 views

ive been searching for 2 days on how to do this. i would like to be "spoon fed" if at all possible, all i want to know is how to take an external text or xml file and allow AS3 to read it into a dynamic text box. i want this as to make it easier to update my website and make changes to the text bodies on each page more conveniently. thank you.

This topic has been closed for replies.

2 replies

Participating Frequently
April 13, 2009

Hi,

Here you go:

var loader:URLLoader = new URLLoader();
    loader.addEventListener(Event.COMPLETE, handle_loadComplete);
    loader.load(new URLRequest("file"));

function handle_loadComplete(e:Event):void
{
    // e.target.data <- your data
    // textField.text = e.target.data
    // var xml:XML = new XML(e.target.data);
}

Participant
April 13, 2009

thank you!

but what is contained in the xml and is this being loaded as a file in my dir in my computer or is it from a website?

Participating Frequently
April 13, 2009

Path to the file can be "http://...file" or just "file", "myDir/file".

If XML looks like this:

<books>

     <book>

          <author>Will Smith</author>

     </book>

     <book>

          <author>Bruce Willis</author>

     </book>

</books>

then the author of the first book in a text field is:

textField.text = xml.book[0].author;

Participant
April 13, 2009

[message removed]