cross scripting is when you load an swf as a child and the child swf can use parent swf functions during runtime and also the parent can call child swf functions on runtime, im going to leave this here because it's useful when making 3d games, when you have a 3d swf you might want to load it up in another swf container to have more perspective and control over the 3d window.
swf 1 name: swf.swf
PHP Code:
var my_var:String = 'hello world';
var myBytes:ByteArray;
var new_player:Loader = new Loader();
var mp_package_ready:Boolean = false;
function load_init_player(){
new_player.contentLoaderInfo.addEventListener(Event.COMPLETE, init_player_loaded);
new_player.load(new URLRequest("var_reader.swf"));
}
function init_player_loaded(e:Event):void{
var myBytes=e.target.bytes;
mp_package_ready=true;
loader.loadBytes(myBytes, loaderInfoStuff);
new_player.contentLoaderInfo.removeEventListener(Event.COMPLETE, init_player_loaded);
}
load_init_player();
var loader:Loader = new Loader();
var loaderInfoStuff:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, cached_mp_loaded);
loaderInfoStuff.allowLoadBytesCodeExecution = true;
loaderInfoStuff.allowCodeImport = true;
function cached_mp_loaded(e:Event):void{
var loaded_mc = e.target.content as MovieClip;
addChild(loaded_mc);
loaded_mc.callit();
loaded_mc.readParent();
}
swf 2 name must be: var_reader.swf
PHP Code:
trace('hey');
function callit(){
trace('hey from callit');
}
function readParent(){
trace(MovieClip(root.parent).my_var);
}