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.

my_so.data.name = "Hector";<br />

trace("before my_so.clear():");<br />

for (var prop in my_so.data) {<br />

trace("\t"+prop);<br />

}<br />

trace("");<br />

my_so.clear();<br />

trace("after my_so.clear():");<br />

for (var prop in my_so.data) {<br />

trace("\t"+prop);<br />

}<br />

Cet exemple <strong>de</strong> co<strong>de</strong> <strong>ActionScript</strong> affiche le message suivant dans le panneau <strong>de</strong> sortie :<br />

before my_so.clear():<br />

name<br />

after my_so.clear():<br />

data (propriété SharedObject.data)<br />

public data : Object<br />

La collecte <strong>de</strong>s attributs associés à la propriété data <strong>de</strong> l'objet. Ces attributs peuvent être<br />

partagés et/ou stockés. Chaque attribut peut être un objet d'un quelconque tableau, nombre,<br />

valeur booléenne, etc. <strong>de</strong> type <strong>ActionScript</strong> ou JavaScript. Par exemple, les lignes suivantes<br />

affectent <strong>de</strong>s valeurs à différents aspects d'un objet partagé :<br />

var items_array:Array = new Array(101, 346, 483);<br />

var currentUserIsAdmin:Boolean = true;<br />

var currentUserName:String = "Ramona";<br />

var my_so:SharedObject = SharedObject.getLocal("superfoo");<br />

my_so.data.itemNumbers = items_array;<br />

my_so.data.adminPrivileges = currentUserIsAdmin;<br />

my_so.data.userName = currentUserName;<br />

for (var prop in my_so.data) {<br />

trace(prop+": "+my_so.data[prop]);<br />

}<br />

Tous les attributs <strong>de</strong> la propriété data <strong>de</strong> données d'un objet partagé sont enregistrés si l'objet<br />

est persistant, et l'objet partagé contient les informations suivantes :<br />

userName: Ramona<br />

adminPrivileges: true<br />

itemNumbers: 101,346,483<br />

Remarque : N'affectez pas directement <strong>de</strong> valeurs à la propriété <strong>de</strong> données data d'un objet<br />

partagé, tel que dans so.data = someValue; Flash ignore ces affectations.<br />

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

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

Saved successfully!

Ooh no, something went wrong!