03.07.2013 Views

Guide de reference du langage ActionScript 2.0 - PowWeb

Guide de reference du langage ActionScript 2.0 - PowWeb

Guide de reference du langage ActionScript 2.0 - PowWeb

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

trace(myMatrix.toString()); // (a=1.6, b=1.2, c=-1.2, d=1.6, tx=100,<br />

ty=200)<br />

myMatrix.scale(2, 2);<br />

trace(myMatrix.toString()); // (a=3.2, b=2.4, c=-2.4, d=3.2, tx=200,<br />

ty=400)<br />

myMatrix.i<strong>de</strong>ntity();<br />

trace(myMatrix.toString()); // (a=1, b=0, c=0, d=1, tx=0, ty=0)<br />

invert (métho<strong>de</strong> Matrix.invert)<br />

public invert() : Void<br />

Effectue la transformation opposée <strong>de</strong> la matrice d'origine. Vous pouvez appliquer une<br />

matrice inversée à un objet pour annuler la transformation effectuée lors <strong>de</strong> l'application <strong>de</strong> la<br />

matrice d'origine.<br />

Disponibilité : <strong>ActionScript</strong> 1.0 ; Flash Player 8<br />

Exemple<br />

L'exemple suivant crée halfScaleMatrix en appelant la métho<strong>de</strong> invert() <strong>de</strong><br />

doubleScaleMatrix, puis démontre que les <strong>de</strong>ux matrices ont été inversées l'une par rapport<br />

à l'autre, annulant ainsi les transformations effectuées par chacune d'entre elles. L'exemple<br />

met en évi<strong>de</strong>nce cette inversion en créant une matrice originalAndInverseMatrix,<br />

équivalente à la matrice noScaleMatrix.<br />

import flash.geom.Matrix;<br />

import flash.geom.Transform;<br />

var rectangleMc_0:MovieClip = createRectangle(20, 80, 0xFF0000);<br />

var rectangleMc_1:MovieClip = createRectangle(20, 80, 0x00FF00);<br />

var rectangleMc_2:MovieClip = createRectangle(20, 80, 0x0000FF);<br />

var rectangleMc_3:MovieClip = createRectangle(20, 80, 0x000000);<br />

var rectangleTrans_0:Transform = new Transform(rectangleMc_0);<br />

var rectangleTrans_1:Transform = new Transform(rectangleMc_1);<br />

var rectangleTrans_2:Transform = new Transform(rectangleMc_2);<br />

var rectangleTrans_3:Transform = new Transform(rectangleMc_3);<br />

var doubleScaleMatrix:Matrix = new Matrix(2, 0, 0, 2, 0, 0);<br />

rectangleTrans_0.matrix = doubleScaleMatrix;<br />

trace(doubleScaleMatrix.toString()); // (a=2, b=0, c=0, d=2, tx=0, ty=0)<br />

var noScaleMatrix:Matrix = new Matrix(1, 0, 0, 1, 0, 0);<br />

rectangleTrans_1.matrix = noScaleMatrix;<br />

rectangleMc_1._x = 100;<br />

trace(noScaleMatrix.toString()); // (a=1, b=0, c=0, d=1, tx=0, ty=0)<br />

Matrix (flash.geom.Matrix) 799

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!