ActionScript Reference

Actionscript3 Send post data along with file upload in AS3

You can pass additional variables to an upload script using either the POST or GET request method. To send additional POST variables to your upload script, you can use the following code:

Actionscript3 Quick AS3 dropshadow filter example

This will add a dropshadow filter to a sprite (here symbolized as the variable oSprite):

For information on the parameters visit the actionscript pages on the dropshadow http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/filters/DropShadowFilter.html

ActionScript convert degrees and radius to coordinates

var degrees=45; radians = degrees* (Math.PI/180); xcoordinate = radius * cos(radians); ycoordinate = radius * sin(radians);

Actionscript3 Move DisplayObject to front or top of displaylist

To move a DisplayObject to the top of the displaylist use the following (where parent is the container of the object being moved to the front). This makes it appear like it's in front of any other DisplayObjects.

Actionscript3 Load a sound and play it

You should preload sounds in as3 before playing them to prevent awkward pauses while the sound effect loads for the first time. To load and play an external sound the following code suffices (in which the first line (pre)loads the file and the second line plays it). Place the first bit in your constructor function and the second in the event handler playing the sound

Actionscript3 ADDED event listener

The stage object can only be accessed after an object has been added to the display list.


ActionScript loading external link - geturl equivalent in AS3

the geturl function that excisted in as2 has been replaced with a call to the navigateToURL method that takes an URLRequest object as it's first argument. Simple example including onclick eventlistener:

Actionscript3 TransitionManager example

A quick example of the transitionmanager in a method:

Actionscript3 Handling Mouse Events in AS3

Possible mouse events are :

Actionscript3 Click handler eventlistener in as3

to capture mouse click event and excute a function :

Actionscript3 handcursor buttonmode

Use this code to show the handcursor when hovering over a displayobject in as3. The cursor turns into a pointing finger similar to the css cursor:pointer directive.

Actionscript3 Fade out function AS3

This function fades out the current stage by drawing a filled rectangle on top of it and tweening the alpha. Can be used for modal by adding a child on top of it.

Actionscript3 Loader class example

This is an example showing an application of the loader class with all it's handlers - this example is from the Flash help files. Usually you don't need all of them but it's handy to have an overview.

ActionScript Post request data in AS3

This simple example shows how to use the URLLoader and URLRequest class in actionscript 3 to post data to a server:

Actionscript3 remove all children from displayobject in actionscript 3

To remove all children from a displayObect in as3 you can use the following loop:

Actionscript3 Scale loader content from/to center in AS3

When tweening, resizing / rescaling an image loaded with the as3 loader class in certain cases it looks neater if it rescales to the center of its parent.

Actionscript3 load xml file as3

xml as3This example shows what to include and some sample code for loading xml data in an AS3 class.

Actionscript2 Flash vars in AS2

When you specify Flash vars in the embed or object tag they become available to actionscript through _root property of the flash file when it loads.

Example html with flash vars :

Actionscript3 tween class example

A Simple example of tween class usage with callback in as3:

Actionscript2 Simple slideshow fade out banner script

Simple slideshow fade in / fade out script in Actionscript2. For a quick flash banner.

Actionscript3 read Flash vars in AS3

Small example illustrating how to get to passed flash vars in AS3

Actionscript3 Call javascript function from AS3 and viceversa

Quick example on how to call a js function via URLRequest:

ActionScript Cachebuster query string

For loading xml data etc. and preventing clientside caching, add it to the url of the file you're retrieving

ActionScript Array shuffle

Array shuffle function. Moves all array values to random positions in the array

ActionScript Array search function

Gosh it's simple.

returns true if the needle variable is found in the haystack array.

Otherwise  returns false.

ActionScript Remove all movieclips from root (or any other object)

This loop removes iterates through an object and removes all movieclips from it.


ActionScript Quick dropshadow filter example

the arguments are:

DropShadowFilter([distance:Number], [angle:Number], [color:Number], [alpha:Number], [blurX:Number], [blurY:Number], [strength:Number], [quality:Number], [inner:Boolean], [knockout:Boolean], [hideObject:Boolean])

for example - where Mc is the movieclip:

Actionscript2 Simple tween example with callback

The callback is in the onMotionFinished handler function. MC is the movieclip the tween will be applied to.

ActionScript Loading an external XML data file with Actionscript

var my_xml = new XML(); my_xml.ignoreWhite = true; // ignore whitespace between xmltags. my_xml.onLoad = function(success){ if (success){ trace(this); } } my_xml.load("my_xml.xml");
[x]