Flash AS3 (actionscript 3) Helps: Flip MovieClip Horizontally with Matrix Class

The Flash Actionscript 3 Matrix class represents a transformation matrix that determines how to map points from one coordinate space to another. You can perform various graphical transformations on a display object by setting the properties of a Matrix object, applying that Matrix object to the matrix property of a Transform object, and then applying that Transform object as the transform property of the display object. These transformation functions include translation (x and y repositioning), rotation, scaling, and skewing.

Here’s a sample that uses the Matrix class to flip a Movie Clip horizontally:

function flipHorizontal(dsp:DisplayObject):void {
var matrix:Matrix=dsp.transform.matrix;
matrix.transformPoint(new Point(dsp.width/2,dsp.height/2));
if (matrix.a>0) {
matrix.a=-1*matrix.a;
matrix.tx=dsp.width+dsp.x;
} else {
matrix.a=-1*matrix.a;
matrix.tx=dsp.x-dsp.width;
}
dsp.transform.matrix=matrix;
}

//usuage
flipHorizontal(myMC)

Related Posts:

Flash AS3 Helps: Catching XML Load Errors, Asynchronously

Not all errors in ActionScript 3 happen when you call a function. Some errors can occur sometime after the call. A common example of this is loading content from the web like XML or other content. Here is a sample of how to catch these types of errors

var myLoader:URLLoader = new URLLoader();

myLoader.addEventListener(IOErrorEvent.IO_ERROR, catchIOError);
function catchIOError(event:IOErrorEvent){
trace("Error caught: "+event.type);
}

myLoader.load(new URLRequest("Invalid XML URL"));
trace("Error, continuing...");

This will output:
Error, continuing...
Error caught: ioError

Related Posts:

Grandma Smith Images

Just a few images I found of grandma on the web. If you find any others on the web, send ‘em over.

Related Posts:

  • No Related Posts