actionscript 3 - Inserting minigames in a bigger flash stage? -
i'm pretty new thing i'm sorry if answer obvious. made couple of 800*640 px minigames in flash, , wondering if there way of including these in master stage, that's 1024*768 , if it's possible pass value of variables between 2 stages, scoring purposes.
inserting external swf:
import flash.display.loader; import flash.net.urlrequest; import flash.events.event; import flash.events.progressevent; function startload() { var loader:loader = new loader(); var urlreq:urlrequest = new urlrequest("directory\\minigame1.swf"); loader.contentloaderinfo.addeventlistener(event.complete, oncompletehandler); loader.contentloaderinfo.addeventlistener(progressevent.progress, onprogresshandler); loader.load(urlreq); } function oncompletehandler(event:event) { movieclip.addchild(event.currenttarget.content); movieclip.x = (stage.stagewidth - movieclip.width) / 2; movieclip.y = (stage.stageheight - movieclip.height) / 2; } function onprogresshandler(event:progressevent) { var percent:number = event.bytesloaded / event.bytestotal; } startload(); you can passing data between two swfs using localconnection :
// sender - minigame1 script var lcs:localconnection = new localconnection(); lcs.send("local_connection1_name", "function_name", "minigame1", 100); // receiver - 'master' script var lcr:localconnection = new localconnection(); lcr.connect("local_connection1_name"); lcr.client = this; function function_name(mg:string,score:int):void { trace(mg + ": " + score) }
Comments
Post a Comment