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.

pow (métho<strong>de</strong> Math.pow)<br />

statique publique pow(x:Number, y:Number) : Number<br />

Calcule et renvoie x à la puissance <strong>de</strong> y.<br />

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

Paramètres<br />

x:Number - Un nombre à élever à une puissance.<br />

y:Number - Un nombre spécifiant la puissance à laquelle le paramètre x est élevé.<br />

Renvoie<br />

Number - Un nombre.<br />

Exemple<br />

L'exemple suivant utilise Math.pow et Math.sqrt pour calculer la longueur d'une ligne.<br />

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

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

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

this.origX = _xmouse;<br />

this.origY = _ymouse;<br />

};<br />

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

this.newX = _xmouse;<br />

this.newY = _ymouse;<br />

var minY = Math.min(this.origY, this.newY);<br />

var nextDepth:Number = canvas_mc.getNextHighestDepth();<br />

var line_mc:MovieClip =<br />

canvas_mc.createEmptyMovieClip("line"+nextDepth+"_mc", nextDepth);<br />

line_mc.moveTo(this.origX, this.origY);<br />

line_mc.lineStyle(2, 0x000000, 100);<br />

line_mc.lineTo(this.newX, this.newY);<br />

var hypLen:Number = Math.sqrt(Math.pow(line_mc._width,<br />

2)+Math.pow(line_mc._height, 2));<br />

line_mc.createTextField("length"+nextDepth+"_txt",<br />

canvas_mc.getNextHighestDepth(), this.origX, this.origY-22, 100, 22);<br />

line_mc['length'+nextDepth+'_txt'].text = Math.round(hypLen) +" pixels";<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 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 />

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

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

Saved successfully!

Ooh no, something went wrong!