Loading a swf file into another swf, in AS3....

  • FlyHigh5
  • Newbie
  • Newbie
  • User avatar
  • Posts: 14

Post 3+ Months Ago


I have this swf file that I am trying to load into another swf file in AS3. In AS2 I used to use the loadMovieNum. Since AS3 does not have loadMovieNum, I have searched the web to find out other solutions. Some of the loader solutions are using the private class, but since the swf file that I'm trying to load is nested inside a movie clip, I get the error message that private cannot be used nested. I found this other suggestion, to use a URL.

whether I put the my swf file on a server (OZZU does not let me post the code to show you!!!) or locally I get the following error message:

Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.

Could anyone please tell me what do I need to do to load my nested swf file inside another swf file in AS3??

Thanks in advance.
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1252
  • Loc: Ro

Post 3+ Months Ago

depends on how you did it :)
But in actionscript 3.0 you need something like this:
Code: [ Select ]
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.display.Loader;

var swfLoader = new Loader();
var urlReq:URLRequest = new URLRequest("myfile.swf");
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, swfLoadComplete);
swfLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, swfLoadError);

function swfLoadComplete(evt:Event):void
var loader:Loader = Loader(evt.target.loader);
swfLoader.removeEventListener(Event.COMPLETE, swfLoadComplete);
function swfLoadError(evt:IOErrorEvent):void
  trace("Unable to load swf ");
  swfLoader.removeEventListener(IOErrorEvent.IO_ERROR, swfLoadError);
  1. import flash.events.Event;
  2. import flash.events.IOErrorEvent;
  3. import flash.net.URLLoader;
  4. import flash.net.URLRequest;
  5. import flash.display.Loader;
  6. var swfLoader = new Loader();
  7. var urlReq:URLRequest = new URLRequest("myfile.swf");
  8. swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, swfLoadComplete);
  9. swfLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, swfLoadError);
  10. swfLoader.load(urlReq);
  11. function swfLoadComplete(evt:Event):void
  12. {
  13. var loader:Loader = Loader(evt.target.loader);
  14. addChild(loader.content);
  15. swfLoader.removeEventListener(Event.COMPLETE, swfLoadComplete);
  16. }
  18. function swfLoadError(evt:IOErrorEvent):void
  19. {
  20.   trace("Unable to load swf ");
  21.   swfLoader.removeEventListener(IOErrorEvent.IO_ERROR, swfLoadError);
  22. }
  • FlyHigh5
  • Newbie
  • Newbie
  • User avatar
  • Posts: 14

Post 3+ Months Ago

Thanks IceCold for the response. I'm sure it's me doing something wrong, the problem is I don't know what I'm doing wrong!! ;)

I tried your code and I get the trace statement: "Unable to load swf".

Here's how I use the code:

My main page is in a movie clip, and has all the page navigation buttons. When the user clicks on a button, my main page action script calls the specific page:

function mainBtn4Down(event:MouseEvent):void {

Page 4 is a movie clip which only has the action script containing the above code, which is supposed to load the swf file for me. That's the part I am stuck at.

Any idea why it does not load?

  • FlyHigh5
  • Newbie
  • Newbie
  • User avatar
  • Posts: 14

Post 3+ Months Ago

I tried it with some test file and it worked. I had a typo on the name of the swf file I've been trying to load!!! Thanks for your help. Little things can sometime add a lot of frustration!!! :))

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 6 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum

© 1998-2017. Ozzu® is a registered trademark of Unmelted, LLC.