import flash.geom.Matrix;
public function flipHorizontal ( dsp:DisplayObject ):void {
var matrix:Matrix = dsp.transform.matrix;
matrix.a = -1;
matrix.tx = dsp.width + dsp.x;
dsp.transform.matrix = matrix;
}
public function flipVertical ( dsp:DisplayObject ):void {
var matrix:Matrix = dsp.transform.matrix;
matrix.d = -1;
matrix.ty = dsp.height + dsp.y;
dsp.transform.matrix = matrix;
}
Links
dreaminginflash.com
Comments Off
Trying to load a directory of hundreds of images into separate movie clips using the AS3 Loader class. By assigning an Event.COMPLETE listener to the Loader, the callback function only has a reference to the Loader and not to the image that’s being loaded or the parent that it’s being loaded into. So if I need to Tween on this image after the load is completed, no dice. Instead, assign an Event.ENTER_FRAME to the parent MovieClip and dig a byte comparison out of the contentLoaderInfo object…
for each ( var imgPath in imgXML.elements () ) {
var imgLoader:Loader = new Loader ();
imgClip.addChild ( imgLoader );
imgClip.addEventListener ( Event.ENTER_FRAME, imgLoading );
imgLoader.load ( new URLRequest ( imgPath ) );
}
…
function imgLoading ( e:Event ):void {
var bL:Number = e.target.getChildAt ( 0 ).contentLoaderInfo.bytesLoaded;
var bT:Number = e.target.getChildAt ( 0 ).contentLoaderInfo.bytesTotal;
if ( bT == bL ) {
e.target.removeEventListener ( Event.ENTER_FRAME, imgLoading );
e.target.parent.Tweener // etc.
}
}
Comments Off
Formatting for the GreenSock TweenLite animation AS3 Class:
TweenLite.to ( mc:MovieClip, duration:Number,
{
alpha:0,
x:120,
ease:Quint.easeInOut,
delay:2,
onComplete:callbackFunction,
onCompleteParams:[ 5, mc ]
}
);
Links
GreenSock
Comments Off
Recently ran across this problem in Actionscript 3 with dynamically naming and retrieving child elements. Created a loop to name sprites and add using the name property and addChild method:
for ( var i:int = 1; i <= 3; i++ ) {
var bkgd:Sprite = new Sprite ();
bkgd.name = "bkgd" +i;
addChild ( bkgd );
}
Now these sprites are accessible via getChildByName and are retrieved as DisplayObject by default. But when retrieved as DisplayObject, you can not add children via addChild method. The trick is to cast the DisplayObject as a Sprite:
var addBkgd:Sprite = Sprite ( this.getChildByName( "bkgd" +layerNum ) );
addBkgd.addChild ( layerSprite );

Comments Off
Create a new movie clip to block the content underneath and apply the following ActionScript:
mc_target.onRollOver = function () {};
mc_target.useHandCursor = false;
Register the empty function so Flash will treat the movie clip like a giant button so that none of the underlying buttons will be active. Add the useHandCursor property to keep the pointer hand from showing up.
Comments Off
clip.slideTo ( x_value, y_value, duration, easing, delay, callback );
Where callback is structure as follows:
{ scope:this, func:”function_name”, args:argvalue }
To send multiple args values, send as an array
Comments Off