0

I'm trying to load two swf files one after the other from the same domain into a main flash player... When The first one is Loaded... it works fine, But when I'm trying to load the other one the first one's actionscript freaks out (stop() function just stops working) In addition, the second one doing some issues with sandbox violation (#2121).

I don't find a reason for this problem...

The Loading code for the first swf:

...
ldr = new Loader();
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, swfLoaded);
ldr.load(new URLRequest(swf1filename));
...
function swfLoaded(e:Event):void {
    mcExt = MovieClip(e.currentTarget.content);
    mcExt.x = 0;
    mcExt.y = 32;
    addChild(mcExt);
}

The Loading code for the second swf:

  ...
function showSWF2(){
        if ( end_movie_swf == null && endMcExt== null ){
            end_movie_swf = new Loader();
            end_movie_swf.contentLoaderInfo.addEventListener(Event.COMPLETE, Swf2Loaded);
            end_movie_swf.load(new URLRequest(endSwffilename));

        }else{
            endMcExt.gotoAndPlay("show");
        }
    }
    ...
function Swf2Loaded(e:Event):void {
    trace(e);
    endMcExt = MovieClip(e.currentTarget.content);
    end_movie_swf.contentLoaderInfo.removeEventListener(Event.COMPLETE, endSwfLoaded);
    endMcExt.x = 0;
    endMcExt.y = 0;
    addChildAt(endMcExt,3);
    endMcExt.gotoAndStop("show");
}

and I'm getting this error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at SWF1::MainTimeline/frame13()
hdmi3killer
  • 89
  • 1
  • 1
  • 12

1 Answers1

0

I would guess that all these three swf's are operating within the same ApplicationDomain. That means that you accidently are using references of same objects in all swf's.

You should try to send a LoaderContext where you tell the loaded swf to operate within its own encapsulated ApplicationDomain.

Like this:

var loaderContext:LoaderContext = new LoaderContext();
loaderContext.applicationDomain = new ApplicationDomain();

ldr.load(new URLRequest(swf1filename),loaderContext);

Do the same with the second Loader object.

Link to resource: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/ApplicationDomain.html

Tjofras
  • 113
  • 8