• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 16. Interfacing with External Data > The LocalConnection Object

The LocalConnection Object

I guess all the new Flash MX features are my favorite because this one is pretty cool too! The Local Connection object enables two separate Flash movies to communicate with each other. Think of it this way: This feature lets one movie trigger functions that are written in another movie. The applications for this are really quite vast. You can have different .swfs in HTML table cells or different frames triggering events in each other. Perhaps, one .swf that contains code and music is placed in a hidden frame, and then when the visitor navigates to different parts of your web site, the music continues to play. Scripts in various other movies can trigger sound effects to play in that hidden movie. Not only does the audio download just once, you won’t hear any breaks in the music as different pages load. This is just one example; I can also see doing something where a pop-up HTML window containing an .swf could trigger scripts present in other windows—perhaps a master controller to play or stop other movies. Again, the hard part is coming up with an idea; the code for LocalConnection objects is really quite simple.


To work through the upcoming code, you need to consider a few things. We’re going to have two movies: receiver.swf and transmitter.swf. We’ll write a function inside receiver.swf and then let transmitter.swf trigger that code. Inside receiver.fla, make a text field with the instance name message, and then put the following code in the first frame:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint