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

L'exemple suivant affiche la légen<strong>de</strong> <strong>de</strong> l'élément <strong>de</strong> menu sélectionné (Pause jeu) dans le<br />

panneau <strong>de</strong> sortie :<br />

var my_cm:ContextMenu = new ContextMenu();<br />

var menuItem_cmi:ContextMenuItem = new ContextMenuItem("Pause Game",<br />

onPause);<br />

my_cm.customItems.push(menuItem_cmi);<br />

function onPause(obj, menuItem) {<br />

trace("You chose: " + menuItem.caption);<br />

}<br />

this.menu = my_cm;<br />

constructeur ContextMenuItem<br />

public ContextMenuItem(caption:String, callbackFunction:Function,<br />

[separatorBefore:Boolean], [enabled:Boolean], [visible:Boolean])<br />

Crée un nouvel objet ContextMenuItem pouvant être ajouté dans le tableau<br />

ContextMenu.customItems.<br />

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

Paramètres<br />

caption:String - Chaîne spécifiant le texte associé à l'élément <strong>de</strong> menu.<br />

callbackFunction:Function - Fonction que vous définissez, appelée lorsque l'élément <strong>de</strong><br />

menu est sélectionné.<br />

separatorBefore:Boolean [facultatif] - Valeur booléenne indiquant si une barre <strong>de</strong><br />

séparation doit apparaître au-<strong>de</strong>ssus <strong>de</strong> l'élément <strong>de</strong> menu <strong>du</strong> menu contextuel. La valeur par<br />

défaut est false.<br />

enabled:Boolean [facultatif] - Valeur booléenne indiquant si l'élément <strong>de</strong> menu est activé<br />

ou désactivé dans le menu contextuel. La valeur par défaut est true.<br />

visible:Boolean [facultatif] - Valeur booléenne indiquant si l'élément <strong>de</strong> menu est visible<br />

ou invisible. La valeur par défaut est true.<br />

Exemple<br />

Cet exemple ajoute les éléments <strong>de</strong> menu Démarrer et Arrêter, séparés par une barre, à l'objet<br />

ContextMenu my_cm. La fonction startHandler() est appelée quand Démarrer est<br />

sélectionné dans le menu contextuel ; stopHandler() est appelé quand Arrêter est<br />

sélectionné. L'objet ContextMenu est appliqué au scénario actuel.<br />

var my_cm:ContextMenu = new ContextMenu();<br />

my_cm.customItems.push(new ContextMenuItem("Start", startHandler));<br />

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

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

Saved successfully!

Ooh no, something went wrong!