With the advent of ActionScript 3.0 and Flash CS3, Adobe took out the possibility of direct access between AS2 and AS3 clips. The next option (besides communication through servers and web services) is local connection. Until now, if you’d create a clip in Flash MX2004 or Flash 8, using AS2, and inside that clip you would load another .swf file (that too created with AS2), both clips would be able to have access to each other’s objects and functions. This is not the case anymore with the new AS3 files. An AS3 clip will not be able to access any objects or functions defined in the AS2 file that it has loaded, and the loaded AS2 file will not be able to access objects and functions defined in its’ parent, the AS3 clip. The only way for the two movie clips to communicate is to use the LocalConnection class. For an unexperienced user this could be a little troublesome: loading the AS2 file, verifying that it’s been correctly loaded, creating LocalConnection objects in both files and trying to connect them in order to be able to execute functions defined inside those files and on the objects existing in those files.
For this reason we developed the ActionScriptBridge components (ASBTerminal for AS2 and ASBContainer for AS3), to ease the work needed to be done so the two AS2 and AS3 movie clips could communicate. The user has only to drag and drop an instance of the components in the AS2 and AS3 clips, define the functions he needs to call and use the run method of the components to call the defined functions.
Now this is still a beta version, but it’s working pretty well. The ASBContainer loads an external AS2 .swf file and the two clips attempt to communicate with each other using LocalConnection objects. The user has only to set the instance names for the two component instances and set the source file to the ASBContainer instance. All the rest is done by the two components: loading the AS2 file and initiating the communication. The connection name for each of the LocalConnection objects is set automatically by the ASBContainer instance. Each connection has a uniquely generated name, encrypted using MD5. Once the ASBContainer has established a communication channel with the ASBTerminal instance, it will not accept any other connection. Each ASBContainer instance should load its’ own AS2 file and there shouldn’t be two ASBContainer instances loading the same file.
Further development will depend on user feedback on this project, so any ideas or comments are welcome.
August 4, 2007 at 12:43 am
G. Skinner just released a class based bridge called SWFBridge, very nice, but more hardly to use, so if you want to check it out, here is the link.
http://www.gskinner.com/blog/archives/2007/07/swfbridge_easie.html
The SWFBridge is a small work around the LocalConnection class, so they have few mistakes inside their bridge, like these:
1. you can’t open the same swf for more than 1 time on one single machine, not in different browsers not even in the same AS3 project, because of their method of using manual setting for connection including a connectionID
2. you can’t expect returns from methods you call
3. you can’t call methods anywhere inside the AS2.0 movie, because you don’t have the scope parameter nor the run command methods.
ActionScriptBridge solved all these problems, and it is the best tool to load AS2.0 content inside AS3.0 projects and use it to communicate back and forth properly.
August 27, 2007 at 4:43 am
I’ve seen a bug with focus between as2 and as3
August 27, 2007 at 4:59 am
Hi freddy,
As I mentioned, this component is still a beta version, so it is possible for bugs to exist. But it would really help us to know exactly what the bug is about.
Thanks.
August 27, 2007 at 6:43 am
well… I’m working with Gmap AS2 component (http://www.afcomponents.com/components/g_map/) into a as3 movie with dropdown and textfileds iu components… when the as2 movie get the focus it’s imposible write in the textfiled(as3) for example because the foucs jump to the as2 movie
August 27, 2007 at 6:47 am
I’m gettin the same trouble with the gskinner class… maybe a localconnection bug?
August 27, 2007 at 6:58 am
ok… the problem is when the as2 movie get the focus and then you try to get the focus in the as3 movie… the as2 movie don’t less the focus
September 4, 2007 at 11:36 pm
I’m sure this is a common issue, it is a Flash Virtual Machine issue, somehow, it acts a bit of this. VM2 focuses and loses focus for VM1, but the VM1 does not even know that it is loaded inside a VM2 movie, and it is not able to lose focus unless you step out of the the entire flash movie or if you reload the as2 content.
There should be some fscommand that you could use to get the focus on the AS3 movie again… from the as2 movie.
You should write to Adobe about this issue, since it is their issue.
September 20, 2007 at 12:44 pm
Just set GMap.enabled = false; and it should work fine. This will disable focus manager for GMap, but nothing else will be effected.