Skip to main content
December 21, 2010
Question

Trying to load external .swf

  • December 21, 2010
  • 1 reply
  • 763 views

import flash.media.Sound; import flash.events.KeyboardEvent; import flash.events.Event; import flash.ui.Keyboard; import flash.net.URLRequest; import flash.display.Loader; var sound:Sound = new songmp3(); sound.play(); var loader:Loader = new Loader(); var mcExternal:MovieClip; addChild(loader); loader.load(new URLRequest("Main.swf")); stage.addEventListener(KeyboardEvent.KEY_DOWN, playGame); function playGame(event:KeyboardEvent):void {      if(event.keyCode == Keyboard.ENTER)      {           //gotoAndPlay(121);           loader.contentLoaderInfo.addEventListener(Event.COMPLETE,swfIn);      } } function swfIn(event:Event):void {      loader.contentLoaderInfo.removeEventListener(Event.COMPLETE,swfIn); }

What exactly am I doing wrong? I want it so that when someone presses enter this .swf files unloads and the Main.swf loads and begins.

This topic has been closed for replies.

1 reply

December 21, 2010

Why wouldn't this work? This is straight from Flash, do I need to publish anything beforehand or should I be able to get Main.swf to load if they are both in the same folder?

import flash.media.Sound; import flash.events.KeyboardEvent; import flash.events.Event; import flash.ui.Keyboard; import flash.net.URLRequest; import flash.display.Loader; var sound:Sound = new songmp3(); sound.play(); var loader:Loader = new Loader(); addChild(loader); var url:URLRequest = new URLRequest("Main.swf"); stage.addEventListener(KeyboardEvent.KEY_DOWN, playGame); function playGame(event:KeyboardEvent):void {      if(event.keyCode == Keyboard.ENTER)      {           loader.load(url);      } }

Ned Murphy
Legend
December 21, 2010

Try posting all your code again if you are still having a problem.  Between the two postings things still don't add up logically.

December 21, 2010

Sorry, those most current code is in the latest post. I'm not sure what else I have to do to make the Main.swf load.