Flash 9 - Learning how to play well with other SWFs

Filed under: Articles — Robert Taylor at 10:32 pm on Sunday, July 9, 2006

UPDATE: FlashInterface has been created as the solution regarding this subject. Please click here for more information.

There is a new kid on the block. Its faster, cooler, and pretty dang impressive! As you may have read, F9P runs in a different virtual machine (VM). I have been looking at doing some projects with AS3 as the backbone, but there is a slight problem. The applications I am looking at building may load SWFs that are not published for Flash 9. In fact, I am expecting it! Now the nasty reality is that F9 doesn’t play too well with other SWFs. Adobe has stated in their official documentation that the only way to have F9 even communicated with SWFs F8 and lower is through LocalConnection. Well, I thought to myself that this wouldn’t be the first time I have hacked my way around what was “official”. But to my surprise, this time they weren’t kidding. LocalConnection IS the only way to communicate.

So in an effort to make my life and everyone else out there who live in the real world and know that Flash 8 SWFs and lower are not going away, I started dinking around with creating a common API to handle this inconvenience.

In this post, I have attached my current work. I will post other related articles and downloads as I find more solutions. You will see in this version that I have a pretty ugly solution. One I have had to succumb to before when dealing with LocalConnection. Instead of using __resolve I have had to use a series of callbacks in a switch statement. The reason for this comes when I need to access native functions to the Flash Player. For example, createEmptyMovieClip or event play, will throw an error when using __resolve and the function.apply technique. This is not something that is new to Flash 9. This is something that has existed in the LocalConnection to __resolve to function.apply technique. Anyway. I am going to continue down this road until a good solution is found. I am going to look at next creating literal tags to support passing complex data objects accross LocalConnection. I am of course limited to the 40k of data, but the main purpose of this is to be able to load a SWF and then communicate with its public API and common timeline functionality.

Here are some things the current solution can do:

  • Talk to native-level functions provided in Flash player through LocalConnection
  • Pass and interpret a full path structure in a single parameter

Here are some things that I have listed on my ToDo list:

  • Pass complex objects in JSON format
  • Pass callback for asynchronouse communication
  • Read in and rename the LocalConnection name so to have multiple VM1 SWFs loaded at the same time.
  • Componentize the solution for both VM1 and VM2 Flash Players

If you have any other items you can think of, suggestions, revisions, tests of your own, add a comment or let me know and I will play around with it.

Download here

2 Comments »

9

Comment by Daniel Larsen

July 13, 2006 @ 1:23 pm

good luck with this….and thanks for the great lecture last night at uflash. you\’ll do great!

10

Comment by Robert Taylor

July 13, 2006 @ 2:54 pm

This is very helpful. Thanks!!!

RSS feed for comments on this post. TrackBack URI

Leave a comment

You must be logged in to post a comment.