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

Cet exemple ajoute le co<strong>de</strong> <strong>ActionScript</strong> suivant à un fichier FLA ou AS dans le même<br />

répertoire qu'une image appelée photo1.jpg :<br />

this.createTextField("coords_txt", this.getNextHighestDepth(), 10, 10, 100,<br />

22);<br />

coords_txt.html = true;<br />

coords_txt.multiline = true;<br />

coords_txt.autoSize = true;<br />

this.createEmptyMovieClip("target_mc", this.getNextHighestDepth());<br />

target_mc._x = 100;<br />

target_mc._y = 100;<br />

target_mc.loadMovie("photo1.jpg");<br />

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

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

var point:Object = {x:_xmouse, y:_ymouse};<br />

target_mc.globalToLocal(point);<br />

var rowHea<strong>de</strong>rs = " &nbsp; \t_x\t_y";<br />

var row_1 = "_root\t"+_xmouse+"\t"+_ymouse;<br />

var row_2 = "target_mc\t"+point.x+"\t"+point.y;<br />

coords_txt.htmlText = "";<br />

coords_txt.htmlText += rowHea<strong>de</strong>rs;<br />

coords_txt.htmlText += row_1;<br />

coords_txt.htmlText += row_2;<br />

coords_txt.htmlText += "";<br />

};<br />

Mouse.addListener(mouseListener);<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 comprend un composant <strong>de</strong> la version<br />

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

MovieClip.getNextHighestDepth().<br />

Voir également<br />

getBounds (métho<strong>de</strong> MovieClip.etBounds), localToGlobal (métho<strong>de</strong><br />

MovieClip.localToGlobal), Object<br />

gotoAndPlay (métho<strong>de</strong> MovieClip.gotoAndPlay)<br />

public gotoAndPlay(frame:Object) : Void<br />

Commence la lecture <strong>du</strong> fichier SWF sur l'image spécifiée. Pour spécifier une séquence et une<br />

image, utilisez gotoAndPlay().<br />

Vous pouvez étendre les métho<strong>de</strong>s et les gestionnaires d'événements <strong>de</strong> la classe MovieClip en<br />

créant une sous-classe.<br />

MovieClip 909

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

Saved successfully!

Ooh no, something went wrong!