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.

Lorsque vous utilisez cet exemple, assurez-vous <strong>de</strong> sélectionner Contrôle > Désactiver les<br />

raccourcis clavier dans l'environnement <strong>de</strong> test.<br />

Voir également<br />

getAscii (métho<strong>de</strong> Key.getAscii), isAccessible (métho<strong>de</strong> Key.isAccessible)<br />

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

statique publique HOME : Number<br />

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

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

Exemple<br />

L'exemple suivant associe une occurrence déplaçable <strong>de</strong> clip intitulée car_mc aux coordonnées<br />

x et y <strong>de</strong> 0,0. Lorsque vous appuyez sur la touche Origine, car_mc renvoie 0,0. Créez un clip<br />

ayant un ID <strong>de</strong> liaison car_id, puis ajoutez le co<strong>de</strong> <strong>ActionScript</strong> suivant sur l'image 1 <strong>du</strong><br />

scénario :<br />

this.attachMovie("car_id", "car_mc", this.getNextHighestDepth(), {_x:0,<br />

_y:0});<br />

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

this.startDrag();<br />

};<br />

car_mc.onRelease = function() {<br />

this.stopDrag();<br />

};<br />

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

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

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

car_mc._x = 0;<br />

car_mc._y = 0;<br />

}<br />

};<br />

Key.addListener(keyListener);<br />

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

Key 703

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

Saved successfully!

Ooh no, something went wrong!