I have created a simple SWF-loader in ActionScript 3.0. It loads an SWF from a server and then plays it. While downloading, it displays the "loading" screen.
Its main defect is that it can load only one Flash application - the one which it is compiled for. Let's say it's named test1.swf.
Is there any way to make the loader support more than one Flash app (for example test2.swf and test3.swf)? I mean by passing external parameters to it and not by creating another loader. Is using Javascript the only way to do it? I don't want my loader to require the Javascript support.
And I really don't want to create separate loaders for all of my apps...
Thanks in advance.
0
votes
1 Answers
1
votes
In order to load an external SWF your loader only need the url of the swf to be loaded, this url doesn't have to be hardcoded. There are many ways to pass parameters to a SWF file and they don't necessarily require Javascript.
You could load a XML file for instance, a simple text file would work too , you could also use a PHP script. Using flahsvars would require Javascript, although only to set your application in your HTML page.
With the following example , your app doesn't need to recompile , you simply change the url in the text file.
Example with a text file containing a url, something like this: http://yourwebsite.com/test1.swf var urlLoader:URLLoader = new URLLoader(); urlLoader.addEventListener(Event.COMPLETE , completeHandler ); urlLoader.load( new URLRequest('swfURL.txt') ); function completeHandler(event:Event):void { loadExternalSWF(event.target.data ); event.target.removeEventListener(Event.COMPLETE , completeHandler ); } function loadExternalSWF(url:String ):void { //your code here , using the url value trace(url );//should return your text file content }