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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

La métho<strong>de</strong> rotate() modifie les propriétés a et d <strong>de</strong> l'objet Matrix. Dans la notation <strong>de</strong>s<br />

matrices, ceci est illustré comme suit :<br />

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

Paramètres<br />

angle:Number - L'angle <strong>de</strong> rotation en radians.<br />

Exemple<br />

L'exemple suivant indique comment la métho<strong>de</strong> rotate() fait pivoter rectangleMc <strong>de</strong> 30<br />

<strong>de</strong>grés vers la droite. L'application <strong>de</strong> myMatrix à rectangleMc redéfinit sa valeur _x, ce qui<br />

vous oblige à la redéfinir sur 100 manuallement.<br />

import flash.geom.Matrix;<br />

import flash.geom.Transform;<br />

var myMatrix:Matrix = new Matrix();<br />

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

var <strong>de</strong>grees:Number = 30;<br />

var radians:Number = (<strong>de</strong>grees/180) Math.PI;<br />

myMatrix.rotate(radians);<br />

trace(myMatrix.toString()); // (a=0.866025403784439, b=0.5, c=-0.5,<br />

d=0.866025403784439, tx=0, ty=0)<br />

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

trace(rectangleMc._x); // 0<br />

rectangleMc._x = 100;<br />

trace(rectangleMc._x); // 100<br />

var rectangleTrans:Transform = new Transform(rectangleMc);<br />

rectangleTrans.matrix = myMatrix;<br />

trace(rectangleMc._x); // 0<br />

rectangleMc._x = 100;<br />

trace(rectangleMc._x); // 100<br />

function createRectangle(width:Number, height:Number,<br />

color:Number):MovieClip {<br />

var <strong>de</strong>pth:Number = this.getNextHighestDepth();<br />

var mc:MovieClip = this.createEmptyMovieClip("mc_" + <strong>de</strong>pth, <strong>de</strong>pth);<br />

mc.beginFill(color);<br />

mc.lineTo(0, height);<br />

802 Chapitre 2: Classes <strong>ActionScript</strong>

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

Saved successfully!

Ooh no, something went wrong!