矩阵基础知识(三)
import flash.display.MovieClip;
import flash.geom.Matrix;
import flash.events.MouseEvent;
var sp:MovieClip=new Container();
var containClone:MovieClip=new Container();
var rect:MovieClip=new Rect();
this.addChild(sp);
sp.x = sp.y = 200;
sp.addChild(rect);
rect.x = 100;
rect.y = 50;
var m0:Matrix = rect.transform.matrix;
var m1:Matrix;
var m2:Matrix;
rectBtn.addEventListener(MouseEvent.CLICK,onClick);
function onClick(e:MouseEvent):void
{
rect.rotation += 10;
m2 = rect.transform.matrix;
//rectBtn.removeEventListener(MouseEvent.CLICK,onClick);
matrixBtn.addEventListener(MouseEvent.CLICK,onClick2);
}
function onClick2(e:MouseEvent):void
{
//matrixBtn.removeEventListener(MouseEvent.CLICK,onClick2);
m1=m0.clone();
m1.invert();
m1.concat(m2);
if(!containClone)containClone=new Container();
containClone.transform.matrix = m1;
sp.addChild( containClone);
}
import flash.geom.Matrix;
import flash.events.MouseEvent;
var sp:MovieClip=new Container();
var containClone:MovieClip=new Container();
var rect:MovieClip=new Rect();
this.addChild(sp);
sp.x = sp.y = 200;
sp.addChild(rect);
rect.x = 100;
rect.y = 50;
var m0:Matrix = rect.transform.matrix;
var m1:Matrix;
var m2:Matrix;
rectBtn.addEventListener(MouseEvent.CLICK,onClick);
function onClick(e:MouseEvent):void
{
rect.rotation += 10;
m2 = rect.transform.matrix;
//rectBtn.removeEventListener(MouseEvent.CLICK,onClick);
matrixBtn.addEventListener(MouseEvent.CLICK,onClick2);
}
function onClick2(e:MouseEvent):void
{
//matrixBtn.removeEventListener(MouseEvent.CLICK,onClick2);
m1=m0.clone();
m1.invert();
m1.concat(m2);
if(!containClone)containClone=new Container();
containClone.transform.matrix = m1;
sp.addChild( containClone);
}