var game:Object;
private function sendToPHP(e:CustomEvent):void
{
var score:Number = e.score;
//send it
}
//load the game.swf
var ldr:Loader = new Loader();
addChild(ldr);
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoad);
ldr.load(new URLRequest("Game.swf"));
private function onLoad(e:Event):void
{
game = LoaderInfo(e.target).content;
game.addEventListener("sendScore", sendToPHP);
}
//Game.as
//call this whenever you want to send score to php
dispatchEvent(new CustomEvent("sendScore", score));
/**
* CustomEvent.as should extend Event and its constructor should update the public
* property score:Number and call super() with the first parameter.
* Feel free to ask if you have any doubts implementing custom events.
* */