1

in flash im calling an external swf file, and image gallery, im using a loader to do it, it works how it should except for one thing, it opens the swf on top of my main flash file, instead of a separate window. i also need to do a back button to take me back to my main flash page and I'm not too sure how to o this.

i need some help i am really struggling with this loader stuff. this is the code for the loader. like i said it works and when i click the button it take mes to the swf file.

var loadedSWF:Loader = null;
function loadSWF(file:String, container:MovieClip=null):void
{
if(container == null) container = MovieClip(root);

// removes the previously loaded SWF
if(loadedSWF != null)
{
    if(loadedSWF.parent) loadedSWF.parent.removeChild(loadedSWF);
}

var req:URLRequest = new URLRequest("imagegallery.swf");
loadedSWF = new Loader();
loadedSWF.load(req);

addChild(loadedSWF);
}
imageGallery_btn.addEventListener(MouseEvent.CLICK, _click);
function _click(e:MouseEvent):void
{
loadSWF("myfile1.swf");
}
}
Jack5848
  • 41
  • 2
  • 6
  • So are you saying that the SWF is being loaded on top of your movie instead of a separate window? Because if that's the case, then that's not possible with AS3 unless you're making a Flash website. – David Feb 01 '13 at 19:27
  • 1
    its hard for me to explain. its not opening in a browser window, its just opens the swf file on top of my main fla file. i.e. my main fla is jack.fla and my image gallery is imagegallery.swf, when i click my image gallery button it opens the swf on top of my fla file that continues to play – Jack5848 Feb 01 '13 at 19:30
  • I applied this only for the gallery.swf, but when I click on Home etc. or other nav links, the gallery.swf is still in front and the content of Home or other appears behind that. Does anyone know how to solve this? Thank you. THIS – Jack5848 Feb 01 '13 at 19:32
  • I think a screenshot of your problem would help. – David Feb 01 '13 at 19:33
  • Oops! Your answer couldn't be submitted because: We're sorry, but as a spam prevention mechanism, new users aren't allowed to post images. Earn more than 10 reputation to post images. – Jack5848 Feb 01 '13 at 19:47
  • Now you should be able to post the image ;) – David Feb 01 '13 at 19:53
  • [1]: http://i.stack.imgur.com/nQjaC.png – Jack5848 Feb 01 '13 at 20:12
  • the image at the front is the swf file that i loaded in with a loader and a button – Jack5848 Feb 01 '13 at 20:12
  • im still struggling with this, ive got my back buttons working all i need is to be able to sort this one problem out. – Jack5848 Feb 02 '13 at 14:16

1 Answers1

0

That is actually the way that it is supposed to work. If you want to open the gallery in a new "window" you need to make it look as if it is a new window. When you call

addChild(loadedSWF);

you are actually telling the loadedSWF to be added to the stage. To add it to a different movieclip you would use this syntax:

whateverMovieClipName.addChild(loadedSWF);

where whateverMovieClipName is the name of the movieclip you want to add the external SWF too.

whodeee
  • 617
  • 5
  • 18