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.

pointMc_0._x = myPoint.x;<br />

var pointMc_1:MovieClip = createRectangle(10, 10, 0x00FF00);<br />

pointMc_1._x = <strong>de</strong>ltaTransformedPoint.x;<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 />

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

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

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

return mc;<br />

}<br />

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

public i<strong>de</strong>ntity() : Void<br />

Définit chaque propriété <strong>de</strong> matrice sur une valeur qui rend un clip ou une construction<br />

géométrique transformé i<strong>de</strong>ntique à l'original.<br />

Après avoir appelé la métho<strong>de</strong> i<strong>de</strong>ntity(), la matrice obtenue est dotée <strong>de</strong>s propriétés<br />

suivantes : a=1, b=0, c=0, d=1, tx=0, ty=0.<br />

Dans la notation <strong>de</strong>s matrices, la matrice d'i<strong>de</strong>ntité a l'aspect suivant :<br />

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

Exemple<br />

L'exemple suivant démontre que l'appel <strong>de</strong> la métho<strong>de</strong> i<strong>de</strong>ntity() convertit l'appel <strong>de</strong><br />

l'objet Matrix en objet Matrix d'i<strong>de</strong>ntité. Le nombre et les types <strong>de</strong> transformation appliqués à<br />

l'objet Matrix d'origine auparavant sont inapplicables. Si la métho<strong>de</strong> i<strong>de</strong>ntity() est appelée,<br />

les valeurs <strong>de</strong> la matrice sont alors converties aux valeurs (a=1, b=0, c=0, d=1, tx=0, ty=0).<br />

import flash.geom.Matrix;<br />

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

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

myMatrix.rotate(Math.atan(3/4));<br />

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

myMatrix.translate(100,200);<br />

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

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

Saved successfully!

Ooh no, something went wrong!