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.

getVolume (métho<strong>de</strong> Sound.getVolume)<br />

public getVolume() : Number<br />

Renvoie le niveau <strong>de</strong> volume sonore en tant qu'entier compris entre 0 et 100, où 0 correspond<br />

à un son coupé et 100 à un volume maximum. Le paramètre par défaut est 100.<br />

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

Valeur renvoyée<br />

Number - Entier.<br />

Exemple<br />

L'exemple suivant crée une glissière avec l'API <strong>de</strong> <strong>de</strong>ssin et un clip est créé lors <strong>de</strong> l'exécution.<br />

Un champ texte créé <strong>de</strong> façon dynamique affiche le niveau <strong>de</strong> volume actuel <strong>du</strong> son lu dans le<br />

fichier SWF. Ajoutez le co<strong>de</strong> <strong>ActionScript</strong> suivant à votre fichier AS ou FLA :<br />

var my_sound:Sound = new Sound();<br />

my_sound.loadSound("song3.mp3", true);<br />

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

knob_mc.left = knob_mc._x;<br />

knob_mc.right = knob_mc.left+100;<br />

knob_mc.top = knob_mc._y;<br />

knob_mc.bottom = knob_mc._y;<br />

knob_mc._x = my_sound.getVolume();<br />

with (knob_mc) {<br />

lineStyle(0, 0x000000);<br />

beginFill(0xCCCCCC);<br />

moveTo(0, 0);<br />

lineTo(4, 0);<br />

lineTo(4, 18);<br />

lineTo(0, 18);<br />

lineTo(0, 0);<br />

endFill();<br />

}<br />

knob_mc.createTextField("volume_txt", knob_mc.getNextHighestDepth(),<br />

knob_mc._width+4, 0, 30, 22);<br />

knob_mc.volume_txt.text = my_sound.getVolume();<br />

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

this.startDrag(false, this.left, this.top, this.right, this.bottom);<br />

this.isDragging = true;<br />

};<br />

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

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

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

Saved successfully!

Ooh no, something went wrong!