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.

get (métho<strong>de</strong> CustomActions.get)<br />

public static get(name:String) : String<br />

Lit le contenu <strong>du</strong> fichier <strong>de</strong> définition XML <strong>de</strong>s actions personnalisées nommé name.<br />

Le nom <strong>du</strong> fichier <strong>de</strong> définition doit être simple, dépourvu <strong>de</strong> l'extension <strong>de</strong> fichier .xml et <strong>de</strong>s<br />

caractères <strong>de</strong> séparation <strong>de</strong> répertoire (« : », « / » ou « \ »).<br />

Si le fichier <strong>de</strong> définition spécifié par le paramètre name est introuvable, une valeur un<strong>de</strong>fined<br />

est renvoyée. Si la définition XML <strong>de</strong>s actions personnalisées spécifiée par le paramètre name<br />

est localisée, elle est lue intégralement et renvoyée sous forme <strong>de</strong> chaîne.<br />

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

Paramètres<br />

name:String - Nom <strong>de</strong> la définition <strong>de</strong>s actions personnalisées à récupérer.<br />

Valeur renvoyée<br />

String - Si la définition XML <strong>de</strong>s actions personnalisées est localisée, renvoie une chaîne ;<br />

sinon, renvoie une valeur un<strong>de</strong>fined.<br />

Exemple<br />

L'exemple suivant répertorie les actions personnalisées dans une occurrence ComboBox et<br />

obtient l'action personnalisée lorsque l'utilisateur clique sur une occurrence Button. Faites<br />

glisser une occurrence <strong>de</strong> ComboBox, Button et TextArea vers la scène. Attribuez à la<br />

ComboBox le nom d'occurrence customActionName_cb, à la TextArea le nom<br />

d'occurrencecustomActionXml_ta et au Button le nom d'occurrence view_button. Entrez le<br />

co<strong>de</strong> <strong>ActionScript</strong> suivant sur l'image 1 <strong>du</strong> scénario :<br />

import mx.controls.*;<br />

var customActionName_cb:ComboBox;<br />

var customActionXml_ta:TextArea;<br />

var view_button:Button;<br />

customActionName_cb.dataProvi<strong>de</strong>r = CustomActions.list();<br />

customActionXml_ta.editable = false;<br />

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

viewListener.click = function(evt:Object) {<br />

var caName:String = String(customActionName_cb.selectedItem);<br />

customActionXml_ta.text = CustomActions.get(caName);<br />

};<br />

view_button.addEventListener("click", viewListener);<br />

CustomActions 489

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

Saved successfully!

Ooh no, something went wrong!