Flip movie clip in Actionscript 3
In this quick post I will show how to flip a movie clip horizontally or vertically using Actionscript 3 code. If you are using the Flash IDE you can flip a movie clip by selecting the Modify > Transform > Flip Horizontal/Vertical from the menu bar. To flip a movie clip with code you can use the following.
movieClipName.scaleX *=-1; //horizontal movieClipName.scaleY *=-1; //vertical
You can also use the Matrix class to flip movie clips.
//horizontal var matrix:Matrix = new Matrix(); matrix.scale(-1,1); matrix.translate((movieClipName.width + movieClipName.x)-movieClipName.width, movieClipName.y); movieClipName.transform.matrix = matrix; //vertical var matrix:Matrix = new Matrix(); matrix.scale(1,-1); matrix.translate(movieClipName.x, (movieClipName.height + movieClipName.y) - movieClipName.height); movieClipName.transform.matrix = matrix
0 comments:
Post a Comment