Grant Davies flew to England to spend Christmas with his folks, having spent 10 years in the States (which he now calls home). So, while he was here, the two of us met up for a couple of days to get some work resolved before the seasonal break.
What we had was an issue getting a Flex 2 movie, which currently loads a Flash 8 movie using SWFLoader, to communicate with said Flash 8 movie. We had already managed to use FlashExtensions FlashInterface control, and were happily passing events between both AVM’s. However, the problems began when wanting to communicate synchronously using method calls. Now, communicating from the embedded AS2 movie to the parent AS3 movie was fine, as FlashInterface was able to retrieve the Flex movie name from the web page it was sitting in, but getting FlashInterface to communicate with the embedded AS2 movie was another matter.
What you would normally have to do is to publish the movie you wish to call, and reference that movie using a path made up of the movie name, followed by the method you wish to call. The method must belong to a class who’s lineage eventually made it to the root timeline, so Singletons were a hassle. I think Grant managed that once, but I don’t think he worked out what he did to get that working
Most of our attempts to resolve this in a way that made sense and could be repeated caused the Flash player to throw a debug window complaining that the movie path we’d specified resolved as a null object, while other attempts would result in no behaviour whatsoever. Totally frustrating. However, Grant did make a find that helped a long way to actually getting paths hooked up correctly using the FlashInterface register method. It turned out the library would check to see if a flashId value is passed to the movie you’re calling, and if that fails, then to use the name of the movie as specified in your HTML code. What it should ideally do, however, is to first check if that flashId value was set in the actual movie, as this is a sure cause of baldness if you are embedding your movie inside another. Now, this wasn’t our ultimate issue, and I won’t go into that, as it turned out to be a completely brainless act on my part, but this will certainly help.
In the original FlashInterface.as file, you have a method called getId, which looks like this:
private static function getId(control:MovieClip):String
{
var root = control
if(root.flashId == null)
{
root.flashId = __swfID;
if(root.flashId == null)
root.flashId = getSWFName(root);
}
return root.flashId;
}
What you really want to do is to return the value of the flashId for that movie first, if it exists. Otherwise, then is the time to start looking elsewhere:
private static function getId(control:MovieClip):String
{
if (_root.flashId != null)
return _root.flashId;
var root = control
if(root.flashId == null)
{
root.flashId = __swfID;
if(root.flashId == null)
root.flashId = getSWFName(root);
}
return root.flashId;
}
}
I hope this helps someone 