Short Tag – Web Development Blog

Entries Tagged ‘URLRequest’

AS3 get file contents, load and work with XML

As3 has a few classes that ease our work with external files (for example with XMLs).
First I will show you how to load an external file:

var file:string = "myfile.txt";
var ur:URLRequest = new URLRequest(file);
var ul:URLLoader = new URLLoader();
ul.addEventListener(Event.COMPLETE, loaded);
ul.load(ur);

function loaded(e:Event):void
{
var str:String = e.target.data;
trace(‘Loaded data is:’+str);
}

In the example above str variable will hold the content of a [...]

ActionScript 3 getURL()

Among the big changes in AS3 is the change of getURL() function. This function has been eliminated from AS3, since this language has became an Object Oriented programming language and it followes the rules of ECMAScript.
In AS2 to open a url (to create a link in flash) we had to use getURL function.
In AS3 we [...]