Search code examples
flashactionscript-2

flash as2: how do i load an external text into a variable? (not loadvars)


I want to be able to load an external text from an http request to a string in my flash application.

i know that with loadvars i can load variables, when the output is as: key=value&key=value.. but this is not the case here. i get in return a string with several random characters. how can i properly retrieve them ?


Solution

  • I resolved the issue by applying toString() on the return object of the onLoad event using an XML object:

    var x = new XML();
    x.load('url');
    x.onLoad = function(success) {
    if (success)
       var data=this.toString();
    }