Copy link to clipboard
Copied
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;
}
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
...Copy link to clipboard
Copied
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);
}
Copy link to clipboard
Copied
Thank you but how does that work with the back button to call this?
Copy link to clipboard
Copied
add the loader.load code to your listener function
Copy link to clipboard
Copied
I'm not sure what you mean. It's already in the code.
Copy link to clipboard
Copied
copy and paste the problematic code.
Copy link to clipboard
Copied
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);
}
Copy link to clipboard
Copied
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);
}
Copy link to clipboard
Copied
I did already try that and I get an error:
Error #1009: Cannot access a property or method of a null object reference.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
It is the correct path. Still same error.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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);
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now