Short Tag – Web Development Blog

Entries Tagged ‘Action Script 3’

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);

function loaded(e:Event):void
var str:String =;
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 [...]

Function To Convert Alpha-RGB to AS3 HEX

function argbtohex(a:Number, r:Number, g:Number, b:Number)
return (a<<24 | r<<16 | g<<8 | b)
This function receives 4 parameters: alpha, red, green and blue, each has it’s values between 0-255.
color = argtohex(255,255,0,0); //red, full alpha
For 100% alpha use the value: 255 and for 0% alpha use 0.
And finally,
The usual happy coding:D