var loader:SWFLoader = new SWFLoader(); |
Then once I figured that out, I wanted to know how to pass parameters into the loaded SWF, and here is how that can be done. Change the load line to:
loader.load("SWFLoaderApp.swf?test=hi"); |
Then in your SWF application code, you should be able to get those parameters like this:
if (application.loaderInfo != null) { |
** Update:
After some more testing I noticed that the above code doesn't always reliably work. And here is what I think is happening. When you start up your main application, the
Application.application
property is set. Then when you load an SWF using the above code, it shares this same application. So, the better way to get at the parameters passed in through the SWFLoader
url is to simply get the parameters
property right from your second (loaded) application like this: // inside your loaded swf application |
From reading the documentation on the mx.core.Application page:
There are two sources of parameters: the query string of the Application's URL, and the value of the FlashVars HTML parameter (this affects only the main Application).
I found this blog quite helpful too in solving this problem:
http://rahulmainkar.blogspot.com/2007/11/swfloader-and-nested-application.html.
1 comment:
Have you tried listening on Event.INIT rather than Event.COMPLETE? In Colin Moock's book, Essential ActionScript 3.0, Chapter 28 suggests to use the Event.INIT event to determine when an asset can be acessed. Event.COMPLETE only signifies the application has been downloaded but not ready for use.
Post a Comment