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 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 />

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

statique publique TAB : Number<br />

La valeur <strong>de</strong> co<strong>de</strong> correspondant à la touche Tab (9).<br />

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

Exemple<br />

L'exemple suivant crée un champ <strong>de</strong> texte et y affiche la date lorsque vous appuyez sur la<br />

touche Tabulation.<br />

this.createTextField("date_txt", this.getNextHighestDepth(), 0, 0, 100,<br />

22);<br />

date_txt.autoSize = true;<br />

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

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

if (Key.isDown(Key.TAB)) {<br />

Key 713

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

Saved successfully!

Ooh no, something went wrong!