Hi there!
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.
views:
34answers:
1
+1
A:
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 }
PatrickS
2010-08-29 16:00:33
Thanks for the answer.Anyway, I don't know how loading XML or a text file can solve my problem, while I have to pass the parameters directly from the webpage which the Flash is displayed on.I think I will finally decide to use Javascript...
rhino
2010-08-29 16:15:09
you can use FlashVars instead
Eugene
2010-08-29 18:57:12
Thanks. :) I didn't know about FlashVars before, now I have looked for it in Google and it seems to be really useful. I will probably use it, thank you.
rhino
2010-09-01 15:06:25