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.

Paramètres<br />

connectionName:String - Une chaîne correspondant au nom <strong>de</strong> connexion spécifié dans la<br />

comman<strong>de</strong> LocalConnection.send() qui souhaite communiquer avec receiving_lc.<br />

Renvoie<br />

Boolean - Une valeur booléenne : true si aucun autre processus en cours d'exécution sur le<br />

même ordinateur client n'a déjà appelé cette comman<strong>de</strong> utilisant la même valeur pour le<br />

paramètre connectionName ; false sinon.<br />

Exemple<br />

L'exemple suivant indique comment un fichier SWF d'un domaine spécifique peut appeler<br />

une métho<strong>de</strong> intitulée printOut dans un fichier SWF <strong>de</strong> réception appartenant au même<br />

domaine.<br />

Tout d'abord, créez un fichier SWF avec le co<strong>de</strong> suivant :<br />

this.createTextField("tf", this.getNextHighestDepth(), 10, 10, 300, 100);<br />

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

aLocalConnection.connect("<strong>de</strong>moConnection");<br />

aLocalConnection.printOut = function(aString:String):Void{<br />

tf.text += aString;<br />

}<br />

Créez ensuite un <strong>de</strong>uxième fichier avec le co<strong>de</strong> suivant :<br />

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

sending_lc.send("<strong>de</strong>moConnection", "printOut", "This is a message from file<br />

B. Hello.");<br />

Pour tester cet exemple, exécutez le premier fichier SWF, puis le second.<br />

Voici un autre exemple. Le fichier SWF 1 contient le co<strong>de</strong> suivant permettant <strong>de</strong> créer un<br />

nouvel objet Sound qui lit un fichier MP3 lors <strong>de</strong> l'exécution. Une barre <strong>de</strong> progression<br />

intitulée playback_pb affiche la progression <strong>de</strong> la lecture <strong>du</strong> fichier MP3. Une occurrence <strong>du</strong><br />

composant Label intitulée song_lbl affiche le nom <strong>du</strong> fichier MP3. Les boutons inclus dans<br />

les différents fichiers SWF seront utilisés pour contrôler la lecture à l'ai<strong>de</strong> d'un objet<br />

LocalConnection.<br />

var playback_pb:mx.controls.ProgressBar;<br />

var my_sound:Sound;<br />

playback_pb.setStyle("themeColor", "haloBlue");<br />

this.createEmptyMovieClip("timer_mc", this.getNextHighestDepth());<br />

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

receiving_lc.playMP3 = function(mp3Path:String, mp3Name:String) {<br />

song_lbl.text = mp3Name;<br />

playback_pb.in<strong>de</strong>terminate = true;<br />

my_sound = new Sound();<br />

my_sound.onLoad = function(success:Boolean) {<br />

LocalConnection 745

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

Saved successfully!

Ooh no, something went wrong!