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.

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

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

parentTrans.matrix = scaleMatrix;<br />

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

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

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

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

scope:MovieClip):MovieClip {<br />

scope = (scope == un<strong>de</strong>fined) ? this : scope;<br />

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

var mc:MovieClip = scope.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 />

matrix (propriété Transform.matrix)<br />

public matrix : Matrix<br />

Objet Matrix <strong>de</strong> transformation contenant <strong>de</strong>s valeurs qui influent sur la mise à l'échelle, la<br />

rotation et la translation <strong>du</strong> clip.<br />

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

Exemple<br />

L'exemple suivant applique l'objet Matrix scaleMatrix à l'objet Transform trans. Cette<br />

Matrix met à l'échelle le MovieClip rect en le multipliant par <strong>de</strong>ux.<br />

import flash.geom.Transform;<br />

import flash.geom.Matrix;<br />

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

var trans:Transform = new Transform(rect);<br />

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

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

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

rect.onPress() = function() {<br />

trans.matrix = scaleMatrix;<br />

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

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

Saved successfully!

Ooh no, something went wrong!