Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Load swf at last frame

Explorer ,
May 31, 2016 May 31, 2016

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;

}

TOPICS
ActionScript
442
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Jun 01, 2016 Jun 01, 2016

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(l

...
Translate
Community Expert ,
May 31, 2016 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);

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 31, 2016 May 31, 2016

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 31, 2016 May 31, 2016

add the loader.load code to your listener function

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 31, 2016 May 31, 2016

I'm not sure what you mean. It's already in the code.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 01, 2016 Jun 01, 2016

copy and paste the problematic code.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 01, 2016 Jun 01, 2016

Thank you so much for your help. I'm so lost now. I've started over a few times.

lastPage2.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF_1);

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);

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 01, 2016 Jun 01, 2016

use:

var loadedSWF:MovieClip;

var loader:Loader=new Loader();

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

lastPage2.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF_1);

function fl_ClickToLoadUnloadSWF_1(e:MouseEvent):void{

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

}

function loadcompleteF(e:Event):void{

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

loadedSWF.gotoAndStop(loadedSWF.totalFrames);

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 01, 2016 Jun 01, 2016

I did already try that and I get an error:

Error #1009: Cannot access a property or method of a null object reference.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 01, 2016 Jun 01, 2016

that's not the code you posted.

use the code i suggested.

if you get a null object error with the code i posted, double check the path/name to your loaded swf.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 01, 2016 Jun 01, 2016

It is the correct path. Still same error.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 01, 2016 Jun 01, 2016

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 01, 2016 Jun 01, 2016
LATEST

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);

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines