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.

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

Vous trouverez également un exemple dans le fichier Strings.fla <strong>du</strong> dossier d'exemples<br />

<strong>ActionScript</strong>. Les chemins type <strong>de</strong> ce dossier sont :<br />

■ Windows : lecteur d'amorçage\Program Files\Macromedia\Flash 8\Samples and<br />

Tutorials\Samples\<strong>ActionScript</strong><br />

■ Macintosh : disque <strong>du</strong>r Macintosh/Applications/Macromedia Flash 8/Samples and<br />

Tutorials/Samples/<strong>ActionScript</strong><br />

getEndIn<strong>de</strong>x (métho<strong>de</strong> Selection.getEndIn<strong>de</strong>x)<br />

public static getEndIn<strong>de</strong>x() : Number<br />

Renvoie l'in<strong>de</strong>x <strong>de</strong> fin <strong>de</strong> la plage <strong>de</strong> sélection ayant actuellement le focus. Si aucun in<strong>de</strong>x<br />

n'existe ou si aucune plage <strong>de</strong> sélection n'a actuellement le focus, la métho<strong>de</strong> renvoie -1. Les<br />

in<strong>de</strong>x <strong>de</strong> plages <strong>de</strong> sélection sont basés sur zéro (par exemple, la première position est 0, la<br />

<strong>de</strong>uxième position est 1, etc.).<br />

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

Valeur renvoyée<br />

Number - Entier.<br />

Exemple<br />

Cet exemple est tiré <strong>du</strong> fichier Strings.fla figurant dans le dossier d'exemples <strong>ActionScript</strong>.<br />

// <strong>de</strong>fine the function which converts the selected text in an instance,<br />

// and convert the string to upper or lower case.<br />

function convertCase(target, menuItem) {<br />

var beginIn<strong>de</strong>x:Number = Selection.getBeginIn<strong>de</strong>x();<br />

var endIn<strong>de</strong>x:Number = Selection.getEndIn<strong>de</strong>x();<br />

var tempString:String;<br />

// make sure that text is actually selected.<br />

if (beginIn<strong>de</strong>x>-1 && endIn<strong>de</strong>x>-1) {<br />

// set the temporary string to the text before the selected text.<br />

tempString = target.text.slice(0, beginIn<strong>de</strong>x);<br />

switch (menuItem.caption) {<br />

case 'Uppercase...' :<br />

// if the user selects the "Uppercase..." context menu item,<br />

// convert the selected text to upper case.<br />

tempString += target.text.substring(beginIn<strong>de</strong>x,<br />

endIn<strong>de</strong>x).toUpperCase();<br />

Sélection 1111

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

Saved successfully!

Ooh no, something went wrong!