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.

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

51 lc.allowDomain = function(aDomain) {<br />

// Allow connections only from mydomain.com<br />

52 return (aDomain == "mydomain.com");<br />

53 }<br />

54 lc.aResult = function(aParam) {<br />

55 trace("The sum is " + aParam);<br />

56 }<br />

// <strong>de</strong>termine our domain and see if we need to truncate it<br />

57 var channelDomain:String = lc.domain();<br />

58 if (getVersion() >= 7 && this.getSWFVersion() >= 7)<br />

59 {<br />

// split domain name into elements<br />

60 var domainArray:Array = channelDomain.split(".");<br />

// if more than two elements are found,<br />

// chop off first element to create superdomain<br />

61 if (domainArray.length > 2)<br />

62 {<br />

63 domainArray.shift();<br />

64 channelDomain = domainArray.join(".");<br />

65 }<br />

66 }<br />

67 lc.connect("result");<br />

68 lc.send("mydomain.com:sum", "aSum", channelDomain + ':' + "result",<br />

"aResult", 123, 456);<br />

Voir également<br />

allowDomain (gestionnaire LocalConnection.allowDomain), connect (métho<strong>de</strong><br />

LocalConnection.connect)<br />

constructeur LocalConnection<br />

public LocalConnection()<br />

Crée un objet LocalConnection.<br />

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

Exemple<br />

L'exemple suivant illustre la manière dont la réception et l'envoi <strong>de</strong> fichiers SWF permettent<br />

<strong>de</strong> créer <strong>de</strong>s objets LocalConnnection. Les <strong>de</strong>ux fichiers SWF peuvent utiliser le même nom<br />

ou <strong>de</strong>s noms différents pour leurs objets LocalConnection respectifs. Dans cet exemple, ils<br />

utilisent <strong>de</strong>s noms différents.<br />

LocalConnection 749

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

Saved successfully!

Ooh no, something went wrong!