Skip to main content
Participating Frequently
May 24, 2010
Answered

Calling a seperate .swf file within anouther swf

  • May 24, 2010
  • 1 reply
  • 788 views

I am trying to make a website that you can press a link in flash that opens up a external swf file within the same area but in a overlay effect... similar to lightbox image viewer.

I have linked in already with the requestURL function but that just opens in a browser window.

any ideas??

Thanks

This topic has been closed for replies.
Correct answer kglad

load the swf using the loader class.

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
May 24, 2010

load the swf using the loader class.

Justin105Author
Participating Frequently
May 24, 2010

Thank you.

I tried this and it worked

Below is the script I used

btnName.addEventListener(MouseEvent.CLICK, tryMeButtonFunction);
function tryMeButtonFunction(event: MouseEvent) {

import flash.net.URLRequest;
import flash.display.Loader;
import flash.events.Event;
import flash.events.ProgressEvent;

  function startLoad() {
   var btnName:Loader = new Loader();
   var mRequest:URLRequest = new URLRequest("file.swf");
   btnName.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
   //btnName.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
   btnName.load(mRequest);
   }

  function onCompleteHandler(loadEvent:Event) {
         addChild(loadEvent.currentTarget.content);
   }
  function onProgressHandler(mProgress:ProgressEvent) {
   var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;
   trace(percent);
   }
  startLoad();
}

Justin105Author
Participating Frequently
May 24, 2010

It would be good if I new how to make it display in the center of my flash file and make the background of everyting else a little darker so it stands out

Justin