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> MovieClip.getNextHighestDepth() utilisée dans cet exemple nécessite Flash<br />

Player 7 ou une version ultérieure. Si votre fichier SWF inclut un composant <strong>de</strong> la version 2,<br />

utilisez la classe DepthManager <strong>de</strong>s composants <strong>de</strong> la version 2 à la place <strong>de</strong> la métho<strong>de</strong><br />

MovieClip.getNextHighestDepth().<br />

LEFT (propriété Key.LEFT)<br />

statique publique LEFT : Number<br />

La valeur <strong>de</strong> co<strong>de</strong> correspondant à la flèche Gauche (37).<br />

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

Exemple<br />

L'exemple suivant déplace un clip intitulé car_mc selon une distance constante (10) lorsque<br />

vous appuyez sur les touches fléchées. Un son est lu lorsque vous appuyez sur la barre d'espace.<br />

Pour cet exemple, affectez l'i<strong>de</strong>ntificateur <strong>de</strong> liaisonhorn_id à un son figurant dans la<br />

bibliothèque.<br />

var DISTANCE:Number = 10;<br />

var horn_sound:Sound = new Sound();<br />

horn_sound.attachSound("horn_id");<br />

var keyListener_obj:Object = new Object();<br />

keyListener_obj.onKeyDown = function() {<br />

switch (Key.getCo<strong>de</strong>()) {<br />

case Key.SPACE :<br />

horn_sound.start();<br />

break;<br />

case Key.LEFT :<br />

car_mc._x -= DISTANCE;<br />

break;<br />

case Key.UP :<br />

car_mc._y -= DISTANCE;<br />

break;<br />

case Key.RIGHT :<br />

car_mc._x += DISTANCE;<br />

break;<br />

case Key.DOWN :<br />

car_mc._y += DISTANCE;<br />

break;<br />

}<br />

};<br />

Key.addListener(keyListener_obj);<br />

Key 707

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

Saved successfully!

Ooh no, something went wrong!