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.

Si vous procé<strong>de</strong>z ainsi, veuillez patienter jusqu'à la fin <strong>du</strong> chargement <strong>du</strong> fichier SWF dans<br />

my_mc car la propriété _url ne dispose pas <strong>de</strong> sa valeur correcte et finale tant que le fichier n'est<br />

pas entièrement chargé. La meilleure façon <strong>de</strong> déterminer si le chargement d'un fichier SWF<br />

enfant est terminé est d'utiliser MovieClipLoa<strong>de</strong>r.onLoadComplete.<br />

La situation opposée peut également se pro<strong>du</strong>ire : Vous pouvez créer un fichier SWF enfant<br />

qui souhaite accepter les appels LocalConnection émanant <strong>de</strong> son parent, mais qui ignore le<br />

domaine <strong>de</strong> ce <strong>de</strong>rnier. Dans ce cas, implémentez cette métho<strong>de</strong> en vérifiant si l'argument <strong>du</strong><br />

domaine correspond au domaine <strong>de</strong> _parent._url. Encore une fois, vous <strong>de</strong>vez analyser le<br />

domaine à partir <strong>de</strong> l'adresse URL complète <strong>de</strong> _parent._url. Dans ce cas, il n'est pas<br />

nécessaire d'attendre la fin <strong>du</strong> chargement <strong>du</strong> fichier SWF parent ; le parent sera déjà chargé<br />

lorsque celui <strong>de</strong> l'enfant commencera.<br />

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

Paramètres<br />

sendingDomain:String [facultatif] - Une chaîne qui spécifie le domaine <strong>du</strong> fichier SWF<br />

contenant l'objet LocalConnection d'envoi.<br />

Exemple<br />

L'exemple suivant illustre la façon dont un objet LocalConnection d'un fichier SWF <strong>de</strong><br />

réception peut permettre aux fichiers SWF d'un domaine quelconque d'invoquer ses<br />

métho<strong>de</strong>s. Comparez cet exemple à celui <strong>de</strong> la métho<strong>de</strong> LocalConnection.connect(), dans<br />

lequel seuls les fichiers SWF appartenant au même domaine peuvent appeler la métho<strong>de</strong><br />

trace() dans le fichier SWF <strong>de</strong> réception. Pour plus d'informations concernant l'utilisation<br />

<strong>du</strong> trait <strong>de</strong> soulignement (_) dans le nom <strong>de</strong> la connexion, consultez<br />

LocalConnection.send().<br />

this.createTextField("welcome_txt", this.getNextHighestDepth(), 10, 10,<br />

100, 20);<br />

var my_lc:LocalConnection = new LocalConnection();<br />

my_lc.allowDomain = function(sendingDomain:String) {<br />

domain_txt.text = sendingDomain;<br />

return true;<br />

};<br />

my_lc.allowInsecureDomain = function(sendingDomain:String) {<br />

return (sendingDomain == this.domain());<br />

}<br />

my_lc.sayHello = function(name:String) {<br />

welcome_txt.text = "Hello, "+name;<br />

};<br />

my_lc.connect("_mylc");<br />

LocalConnection 739

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

Saved successfully!

Ooh no, something went wrong!