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.

_xmouse (propriété TextField._xmouse)<br />

public _xmouse : Number [lecture seule]<br />

Renvoie la coordonnée x <strong>de</strong> la position <strong>de</strong> la souris par rapport au champ texte.<br />

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

Exemple<br />

L'exemple suivant crée trois champs texte sur la Scène. L'occurrence mouse_txt affiche la<br />

position actuelle <strong>de</strong> la souris par rapport à la Scène. L'occurrence textfield_txt affiche la<br />

position actuelle <strong>du</strong> pointeur <strong>de</strong> la souris par rapport à l'occurrence my_txt. Ajoutez le co<strong>de</strong><br />

<strong>ActionScript</strong> suivant à un fichier FLA ou AS :<br />

this.createTextField("mouse_txt", this.getNextHighestDepth(), 10, 10, 200,<br />

22);<br />

mouse_txt.bor<strong>de</strong>r = true;<br />

this.createTextField("textfield_txt", this.getNextHighestDepth(), 220, 10,<br />

200, 22);<br />

textfield_txt.bor<strong>de</strong>r = true;<br />

this.createTextField("my_txt", this.getNextHighestDepth(), 100, 100, 160,<br />

120);<br />

my_txt.bor<strong>de</strong>r = true;<br />

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

mouseListener.onMouseMove = function() {<br />

mouse_txt.text = "MOUSE ... X:" + Math.round(_xmouse) + ",\tY:" +<br />

Math.round(_ymouse);<br />

textfield_txt.text = "TEXTFIELD ... X:" + Math.round(my_txt._xmouse) +<br />

",\tY:" +<br />

Math.round(my_txt._ymouse);<br />

}<br />

Mouse.addListener(mouseListener);<br />

La métho<strong>de</strong> MovieClip.getNextHighestDepth() utilisée dans cet exemple requiert Flash<br />

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

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

MovieClip.getNextHighestDepth().<br />

Voir également<br />

_ymouse (propriété TextField._ymouse)<br />

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

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

Saved successfully!

Ooh no, something went wrong!