Actionscript:
-
var box:Shape = Shape(addChild(new Shape()));
-
with (box.graphics) beginFill(0x006666), drawRect(0,0,50,50);
-
box.x = box.y = 100;
-
-
addEventListener(Event.ENTER_FRAME, onLoop);
-
-
function onLoop(evt:Event):void {
-
-
var m:Matrix = box.transform.matrix;
-
// skew on the X
-
m.c = (mouseX - stage.stageWidth / 2 ) / stage.stageWidth;
-
-
// skew on the Y
-
// m.b = (mouseX - stage.stageWidth / 2 ) / stage.stageWidth
-
-
box.transform.matrix = m
-
}
This skews a box Shape using the c and b properties of the transformation matrix. Note that these values don't match those in the IDE's transform window. This is good further reading if your interested in this topic.