- Problem:
Create communication between flex and flash swf when using SWFLoader.
note: embeding a swc might be the solution for some people. I use it a lot, it works fine. But this time I want to load at run time. Don’t want to embed because it would increase the size of my flex swf.
- Hints:
http://www.gskinner.com/blog/archives/2007/07/swfbridge_easie.html
http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_16243
http://kanuwadhwa.wordpress.com/2007/09/20/communication-between-swf-files/
http://css.dzone.com/news/passing-data-between-flash-and
- Solutions:
– - Local connection
Source code here, “Save Link As” on your desktop and change extention to .zip
- – Event Access (best solution)
Source code here, “Save Link As” on your desktop and change extention to .zip
- Conclusion:
It works but you need to be carefull with the local connection. Don’t forget to close it.
I recommand the access through event in combination with DTO (data transfere object) to pass variables.
I have yet to look into this but in this link:
The guy load the class definition of the external swf file opening the door to an open communication between 2 swf fully knowing each others variables and functions, isn’t it?
<pre>package com.scottgmorgan {
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.Event;
import flash.display.LoaderInfo;
import flash.display.Sprite;
import flash.system.ApplicationDomain;
public class SourceMovie extends Sprite {
public function SourceMovie():void {
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
loader.load(new URLRequest('ExternalMovie.swf'));
}
private function onLoadComplete(e:Event):void {
ApplicationDomain.currentDomain.getDefinition("com.scottgmorgan.ExternalMovie");
var myExternalMovie:ExternalMovie = ExternalMovie(e.target.content);
myExternalMovie.alert('Hello World');
}
}
}
Tags: communication, flash, flex, swfloader