Share Posted October 7, 2010 Hi so, I'm using a loadermax as a preloader its ease, simple and works great. However I need to pass string date to my main swf file and not the preloader what's the best solution for this, can laodermax pass date between swf files? Here is my current code - /* Create the swf loader */ _swfLoader = new SWFLoader("main.swf",{alpha:0,container:this,name:"mainSWF",x:0,y:0,estimatedBytes:3500,scaleMode:"none",crop:true,onProgress:progressHandler,onComplete:_completeHandler, onError:_errorHandler}); _swfLoader.load(true); Thanks, Almog Link to comment Share on other sites More sharing options...
Share Posted October 7, 2010 You can certainly use the SWFLoader's rawContent to pass data. function completeHandler(event:LoaderEvent):void { var mc:MovieClip = mySWFLoader.rawContent; mc.setCustomData(flashVar1, flashVar2); //you create the setCustomData() method in your main class } But it's probably cleaner to just access the stage's loaderInfo to get the parameters directly. Just make sure you wait until the child swf is added to the display list to run the code, otherwise "stage" will be null. //in your child: if (this.stage != null) { init(null); } else { addEventListener(Event.ADDED_TO_STAGE, init); } function init(event:Event=null):void { removeEventListener(Event.ADDED_TO_STAGE, init); var myVar1:String = this.stage.loaderInfo.parameters.myFlashVar; } Link to comment Share on other sites More sharing options...
Share Posted October 11, 2010 You can certainly use the SWFLoader's rawContent to pass data. function completeHandler(event:LoaderEvent):void { var mc:MovieClip = mySWFLoader.rawContent; mc.setCustomData(flashVar1, flashVar2); //you create the setCustomData() method in your main class } But it's probably cleaner to just access the stage's loaderInfo to get the parameters directly. Just make sure you wait until the child swf is added to the display list to run the code, otherwise "stage" will be null. //in your child: if (this.stage != null) { init(null); } else { addEventListener(Event.ADDED_TO_STAGE, init); } function init(event:Event=null):void { removeEventListener(Event.ADDED_TO_STAGE, init); var myVar1:String = this.stage.loaderInfo.parameters.myFlashVar; } Im having the same problem. How can I send the vars to the SWF? I tried this: // first try queue.append( new SWFLoader("swf/" + game, {name:"activeGame", estimatedBytes:3000, container:this, x:0, autoPlay:true, requireWithRoot:this.root}) ); //second try queue.append( new SWFLoader("swf/" + game, {name:"activeGame", estimatedBytes:3000, container:this, x:0, autoPlay:true, FlashVars:"Joe=test"}) ); How can I declare the vars into the child SWF? Link to comment Share on other sites More sharing options...
Share Posted October 11, 2010 I already provided two solutions above - did you try those? Link to comment Share on other sites More sharing options...
Author Share Posted October 12, 2010 Thanks works great. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now