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.

}<br />

mc.curveTo(r+x, -Math.tan(Math.PI/8)*r+y, r+x, y);<br />

Voir également<br />

acos (métho<strong>de</strong> Math.acos), asin (métho<strong>de</strong> Math.asin), atan (métho<strong>de</strong> Math.atan),<br />

atan2 (métho<strong>de</strong> Math.atan2), cos (métho<strong>de</strong> Math.cos), tan (métho<strong>de</strong> Math.tan)<br />

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

statique publique sqrt(x:Number) : Number<br />

Calcule et renvoie la racine carrée <strong>du</strong> nombre spécifié.<br />

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

Paramètres<br />

x:Number - Un nombre ou une expression supérieur(e) ou égal(e) à 0.<br />

Renvoie<br />

Number - Un nombre si le paramètre x est supérieur ou égal à zéro ; NaN (pas un nombre)<br />

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

Math 783

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

Saved successfully!

Ooh no, something went wrong!