- Home /
Embedding a unity-generated swf in another one
Hello. I have two silly unity generated swfs and I want one to be loaded and displayed within the other. I've tryed:
ActionScript.Import("flash.display.Loader");
ActionScript.Import("com.unity.UnityNative");
ActionScript.Import("flash.net.URLRequest");
ActionScript.Statement("var myLoader : Loader = new Loader;");
ActionScript.Statement("var url : URLRequest = new URLRequest(\"Cena2Loader.swf\");");
ActionScript.Statement("myLoader.load(url);");
ActionScript.Statement("UnityNative.stage.addChild(myLoader);");
But I get the following error:
Fatal Error : RangeError: Error #1506:
The specified range is invalid.
at com.unity::UnityNative$/NativeExt_PlayerLoop()
at com.unity::UnityContentInternal/playerLoop()
at com.unity::UnityContent/onEnterFrame()
Native_Init called while already initialized
I have also tryed creating a custom preloader swf for the second one, but no success so far. Any ideas?
Answer by catburton · Aug 02, 2012 at 10:36 AM
Loading one Unity SWF and adding it to the stage of another Unity SWF in this way is not supported.
If you wish to load Unity content from external SWFs, you could use asset bundles for this. This would allow you to load scenes/assets etc at runtime. Using asset bundles for Flash export works the same way as other asset bundles, you just need to ensure the target is set to FlashPlayer.
If, on the other hand, you simply want to embed your Unity SWF within a standard SWF, there is an example of how to do this on the forums: http://forum.unity3d.com/threads/145294-Flash-Custom-Splash-Screen-Single-SWF
If neither of those options are viable for your project, please provide more details on the effect you're trying to achieve and why those projects need to be separate SWFs.
Answer by Azis · Aug 03, 2012 at 04:43 PM
Thanks for the answer. I'm building a unity system flash-targeted composed of independent SWF modules (some are 3rd party). Some of these modules are unity-made, but not all of them.
Therefore, it is necessary to load SWF modules inside my Unity project, unity-made or not.
About the use of AssetBundles, I wonder if I will be able to load content directly from the SWF, something like:
WWW("http://myserver/moduleX.swf").assetBundle.assetX
The second option will not suit me since I'm working with two unity-based SWFs.
Your answer
Follow this Question
Related Questions
flash preloader in unity web player 0 Answers
Unity3d 3.5 Build to flash error dump debug 0 Answers
Error #2044 in flash build 2 Answers
Exported SWF no longer loads 1 Answer
Screen Flash When Hit -- Error Help From Pervious Question's Answer 1 Answer