all groups > flash actionscript > april 2006 >
You're in the

flash actionscript

group:

Music player with 2 swfs using LocalConnection


Music player with 2 swfs using LocalConnection outshineweb
4/28/2006 11:33:19 PM
flash actionscript: Hello,

I'm creating a site that will have two seperate SWFs on screen. One will be
playing music, the other will contain a start/stop button for the music. I'm
using LocalConnection to communicate between the two SWFs.
I have this working, sort of. The music will start playing, I can stop it,
restart it and stop it again, but the second time I attempt to restart it, it
does nothing. You can view it at:

http://www.outshinewebdesign.com/spider/index.html

For the life of me, I cannot figure out what is happening that it won't
restart the second time. This is the first time I have attempted to use
LocalConnection, so I'm hoping this is just a small syntax error on my part.

I zipped up all relevant files and have placed it online at:

http://www.outshinewebdesign.com/spi...connection.zip

If anyone is inclined to take a peak. I'll also post an outline of what I am
doing.

The movie that contains the controls is sending the LocalConnection data with
the following AS:

(Frame 1, stopping music)


Code:
buttonInstance.onRelease = function() {

outgoing_lc = new LocalConnection();
outgoing_lc.send("lc_name", "methodToExecute", 2);
delete outgoing_lc;
_root.gotoAndStop(2);

};

(Frame 2, playing music)


Code:
buttonInstance.onRelease = function() {

outgoing_lc = new LocalConnection();
outgoing_lc.send("lc_name", "methodToExecute", 1);
delete outgoing_lc;
_root.gotoAndStop(1);

};

The movie with the music that is receiving the LocalConnection data is
receiving with the following AS:

Code:

incoming_lc = new LocalConnection();
incoming_lc.methodToExecute = function (param) {

if (param == 1) {
gotoAndPlay(1);
musicStatus = "Playing";
} else {
gotoAndStop(20);
musicStatus = "Stopped";
}

}

incoming_lc.connect("lc_name");

I've tried everything I can think of, including rewriting everything multiple
times, but I'm getting the same result. I don't understand why it works the
first couple of times, but then stops. I very much appreciate anyone's insight
on this issue. Thanks!

Luke
Re: Music player with 2 swfs using LocalConnection outshineweb
4/28/2006 11:43:29 PM
Figured it out! I simply needed to add:

incoming_lc.connect("lc_name");

To the last frame, to ensure that the movie continued to listen for the LocalConnection data.
AddThis Social Bookmark Button