Skip to main content
Inspiring
May 31, 2016
Answered

Load swf at last frame

  • May 31, 2016
  • 1 reply
  • 529 views

Hello,

I have several swfs that are meant to be read in order (like a book). I can load the previous swf but I need it to go to the the last frame. Can this be done with the code I have?

lastPage2.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF_1);

import fl.display.ProLoader;

var fl_ProLoader_1:ProLoader;

var fl_ToLoad_1:Boolean = true;

function fl_ClickToLoadUnloadSWF_1(event:MouseEvent):void

{

  if(fl_ToLoad_1)

  {

  fl_ProLoader_1 = new ProLoader();

  fl_ProLoader_1.load(new URLRequest("CEAS_I_1_16.swf"));

  addChild(fl_ProLoader_1);

  }

  else

  {

  fl_ProLoader_1.unload();

  removeChild(fl_ProLoader_1);

  fl_ProLoader_1 = null;

  }

  fl_ToLoad_3 = !fl_ToLoad_1;

}

This topic has been closed for replies.
Correct answer chandranoel

if that's your only code, lastPage2 is undefined.

if you have other code, click file>publish settings>tick permit debugging.  retest.

the line number with your undefined object will be in the error message.


It doesn't work at all but I was able to find a different code you suggested on another thread: Going to specific frame of external swf

This worked!

var loadmod2:Loader;

lastSection.addEventListener(MouseEvent.CLICK, loadlast);

function loadlast(e:MouseEvent):void

{

if(!loadmod2){

  loadmod2 = new Loader();

loadmod2.contentLoaderInfo.addEventListener(Event.COMPLETE,loadCompleteF);

}

  loadmod2.load(new URLRequest("CEAS_I_1_16.swf"));

}

function loadCompleteF(e:Event):void{

  addChild(loadmod2);

  MovieClip(loadmod2.content).gotoAndPlay(33);

}

1 reply

kglad
Community Expert
Community Expert
May 31, 2016

you need to use a complete listener and then direct the loaded swf to its last frame. because i never found a use for proloader, i use the loader class:

var loader:Loader=new Loader();

loader.contentLoaderInfo.addEventListener(Event.COMPLETE,loadcompleteF);

loader.load(new URLRequest('CEAS_I_1_16.swf'));

var loadedSWF:MovieClip;

function loadcompleteF(e:Event):void{

loadedSWF=MovieClip(e.target.loader.content);

loadedSWF.gotoAndStop(loadedSWF.totalFrames);

}

Inspiring
June 1, 2016

Thank you but how does that work with the back button to call this?