Skip to main content
Holeycow
Known Participant
June 30, 2011
Question

Going to specific frame of external swf

  • June 30, 2011
  • 1 reply
  • 4689 views

Hello

I've got another little hitch that I've come accross in the project that I'm currently assembling.

From time to time I need to load swf files at specific frames & seem to have hit a brick wall.

The code I'm using is

var loadmod2:Loader;

BackBut.addEventListener(MouseEvent.CLICK, Goneg);

function Goneg(e:MouseEvent):void
{
  loadmod2 = new Loader();
  loadmod2.load(new URLRequest("mod2.swf"));
  addChild(loadmod2);
  gotoAndPlay(18);
}

It loads the right swf, but at frame 1, when I want tp load it at frame 18

Trying to search for a solution has just left me even more confused. The solutions put forward seem complex, and I just can't get them to work.

As usual, any help would be greatly appreciated.

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
June 30, 2011

use:


var loadmod2:Loader;

BackBut.addEventListener(MouseEvent.CLICK, Goneg);

function Goneg(e:MouseEvent):void
{

if(!loadmod2){
  loadmod2 = new Loader();

loadmod2.addEventListener(Event.COMPLETE,loadCompleteF);

}
  loadmod2.load(new URLRequest("mod2.swf"));
}

function loadCompleteF(e:Event):void{
  addChild(loadmod2);
  MovieClip(loadmod2.content).gotoAndPlay(18);

}
Holeycow
HoleycowAuthor
Known Participant
June 30, 2011

Thanks kglad........I tried the code you put up, but it started playing the sound from the mod2.swf, but from frame 1 & with no vision.

relaxatraja
Inspiring
June 30, 2011

try also with the init:

//Loading clips content
var ldr:Loader;
var mcExt:MovieClip;

//Loading
loadswf("test.swf");
function loadswf(tmp:String):void{
     unloadSwf();
     passedString=tmp;
     ldr= new Loader();
     ldr.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressListener);
     ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, swfLoaded);
     ldr.contentLoaderInfo.addEventListener(Event.INIT, initListener);
     ldr.load(new URLRequest(tmp));
        
     function progressListener (e:ProgressEvent):void{
         //ploader.visible=true;
     }
    
     function initListener (e:Event):void{
         mcExt = e.target.content as MovieClip;
         mcExt.stop();
     }
    
     function swfLoaded(e:Event):void {
         mcExt = e.target.content as MovieClip;
         ldr.contentLoaderInfo.removeEventListener(Event.COMPLETE, swfLoaded);
         //ploader.visible=false;
         addChild(mcExt);
         mcExt.gotoAndPlay(20);
     }
}

//UnLoading

function unloadSwf():void{

    if (ldr!=null){

        ldr.unloadAndStop();

        removeChild(mcExt);

        mcExt=null;

    }

}