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.

Exemple<br />

L'exemple suivant illustre comment utiliser cette métho<strong>de</strong>. Pour utiliser ce co<strong>de</strong>, sur la Scène,<br />

créez un champ texte statique contenant le texte « AB ». Faites pivoter le champ texte <strong>de</strong> 45<br />

<strong>de</strong>grés et définissez le <strong>de</strong>uxième caractère dans le style exposant avec une couleur <strong>de</strong><br />

0xFFFFFF, avec un alpha <strong>de</strong> 50%, comme dans l'illustration suivante :<br />

Le script suivant répertorie les propriétés getTextRunInfo() <strong>de</strong> chaque caractère dans le<br />

champ texte :<br />

var myTS:TextSnapshot = this.getTextSnapshot();<br />

var myArray:Array = myTS["getTextRunInfo"](0, myTS.getCount());<br />

for (var i = 0; i < myTS.getCount(); i++) {<br />

trace("in<strong>de</strong>xInRun: " + myArray[i].in<strong>de</strong>xInRun);<br />

trace("selected: " + myArray[i].selected);<br />

trace("font: " + myArray[i].font);<br />

trace("color: " + <strong>de</strong>cToHex(myArray[i].color));<br />

trace("height: " + myArray[i].height);<br />

trace("matrix_a: " + myArray[i].matrix_a);<br />

trace("matrix_b: " + myArray[i].matrix_b);<br />

trace("matrix_c: " + myArray[i].matrix_c);<br />

trace("matrix_d: " + myArray[i].matrix_d);<br />

trace("matrix_ty: " + myArray[i].matrix_tx);<br />

trace("matrix_tx: " + myArray[i].matrix_ty);<br />

trace(" ");<br />

}<br />

function <strong>de</strong>cToHex(<strong>de</strong>c:Number) {<br />

var hexString:String = "";<br />

if (<strong>de</strong>c > 15) {<br />

hexString = <strong>de</strong>cToHex(Math.floor(<strong>de</strong>c / 16));<br />

}<br />

var hexDigit = <strong>de</strong>c - 16 * (Math.floor(<strong>de</strong>c / 16));<br />

if (hexDigit > 9) {<br />

hexDigit = String.fromCharCo<strong>de</strong>(hexDigit + 55);<br />

}<br />

hexString = hexString + hexDigit;<br />

return hexString;<br />

}<br />

Ceci crée la sortie suivante :<br />

in<strong>de</strong>xInRun: 0<br />

selected: false<br />

font: Times New Roman<br />

color: FF000000<br />

height: 28.6<br />

matrix_a: 0.0316612236983293<br />

matrix_b: 0.0385940558426864<br />

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

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

Saved successfully!

Ooh no, something went wrong!