topical media & game development
animation-ch18-SkewX.ax
animation-ch18-SkewX.ax
[swf]
[flash]
flex
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.Matrix;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
public class @ax-animation-ch18-SkewX extends Sprite
{
private var box:Sprite;
public function @ax-animation-ch18-SkewX()
{
init();
}
private function init():void
{
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
box = new Sprite();
box.graphics.beginFill(0xff0000);
box.graphics.drawRect(-50, -50, 100, 100);
box.graphics.endFill();
addChild(box);
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(event:Event):void
{
var skewX:Number = (mouseX - stage.stageWidth / 2) * .01;
box.transform.matrix = new Matrix(1, 0,
skewX, 1,
stage.stageWidth / 2,
stage.stageHeight / 2);
}
}
}
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.