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.

var shortcut = this._parent._parent.name_txt; shortcut.text = "Hank";<br />

shortcut.autoSize = true;<br />

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

Paramètres<br />

object:Object - Occurrence <strong>de</strong> l'objet <strong>ActionScript</strong> ou <strong>du</strong> clip.<br />

Exemple<br />

L'exemple suivant définit les propriétés _x et _y <strong>de</strong> l'occurrence someOther_mc, puis indique<br />

à someOther_mc <strong>de</strong> se rendre à l'image 3 et <strong>de</strong> s'arrêter.<br />

with (someOther_mc) {<br />

_x = 50;<br />

_y = 100;<br />

gotoAndStop(3);<br />

}<br />

Le fragment <strong>de</strong> co<strong>de</strong> suivant indique comment écrire le co<strong>de</strong> qui précè<strong>de</strong> sans instruction<br />

with.<br />

someOther_mc._x = 50;<br />

someOther_mc._y = 100;<br />

someOther_mc.gotoAndStop(3);<br />

L'instruction with est utile pour accé<strong>de</strong>r à plusieurs éléments dans la liste <strong>de</strong> chaîne <strong>de</strong><br />

domaine <strong>de</strong> manière simultanée. Dans l'exemple suivant, l'objet Math intégré est placé au<br />

début <strong>de</strong> la chaîne <strong>de</strong> domaine. Déterminer Math comme objet par défaut convertit<br />

respectivement les i<strong>de</strong>ntificateurs cos, sin, et PI en Math.cos, Math.sin, et Math.PI. Les<br />

i<strong>de</strong>ntificateurs a, x, y, et rne sont pas <strong>de</strong>s métho<strong>de</strong>s ou <strong>de</strong>s propriétés <strong>de</strong> l'objet Math mais,<br />

puisqu'ils existent dans le domaine d'activation d'objet <strong>de</strong> la fonction polar(), ils renvoient<br />

aux variables locales correspondantes.<br />

function polar(r:Number):Void {<br />

var a:Number, x:Number, y:Number;<br />

with (Math) {<br />

a = PI * pow(r, 2);<br />

x = r * cos(PI);<br />

y = r * sin(PI / 2);<br />

}<br />

trace("area = " + a);<br />

trace("x = " + x);<br />

trace("y = " + y);<br />

} polar(3);<br />

Le résultat suivant s'affiche dans le panneau <strong>de</strong> sortie.<br />

area = 28.2743338823081<br />

x = -3<br />

y = 3<br />

Instructions 243

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

Saved successfully!

Ooh no, something went wrong!