03.05.2013 Views

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Returns<br />

Boolean - A Boolean value: true if no other process running on the same client computer has<br />

already issued this comm<strong>and</strong> using the same value for the connectionName parameter; false<br />

otherwise.<br />

Example<br />

The following example shows how a SWF file in a particular domain can invoke a method<br />

named printOut in a receiving SWF file in the same domain.<br />

First, create one SWF file with the following code:<br />

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

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

aLocalConnection.connect("demoConnection");<br />

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

tf.text += aString;<br />

}<br />

Then create a second with the following code:<br />

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

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

B. Hello.");<br />

To test this example, run the first SWF file, <strong>and</strong> then run the second one.<br />

Here is another example. SWF 1 contains the following code, which creates a new Sound<br />

object that plays back an MP3 file at runtime. A ProgressBar called playback_pb displays the<br />

playback progress of the MP3 file. A Label component instance called song_lbl displays the<br />

name of the MP3 file. Buttons in different SWF files will be used to control the playback<br />

using a LocalConnection object.<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.indeterminate = true;<br />

my_sound = new Sound();<br />

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

playback_pb.indeterminate = false;<br />

};<br />

my_sound.onSoundComplete = function() {<br />

delete timer_mc.onEnterFrame;<br />

};<br />

timer_mc.onEnterFrame = function() {<br />

playback_pb.setProgress(my_sound.position, my_sound.duration);<br />

730 <strong>ActionScript</strong> classes

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

Saved successfully!

Ooh no, something went wrong!