Highlighted

Code to reset entire Stage

Explorer ,
Jul 09, 2019

Copy link to clipboard

Copied

I am a novice user.  I have a project in Animate where I have two external swfs that load.  Everything loads and unloads fine when you first click a button to load it, then unload it.  The problem is that once I load and unload, the other swf will not load.  Whichever one I click first will load and unload.  I don't know why this is happening.  I use a projector file (publish export) and this is where it doesn't work.  Everything works fine when I simply do a test scene.

So here is my question.  When I go back to the page where the buttons are, is there a code that I can put on frame one so that when the playhead reaches that frame it resets everything?  In my mind this is the solution to circumventing this issue.

I have tried to do multiple searches for such code and cannot find anything.

Paul

Adobe Community Professional
Correct answer by kglad | Adobe Community Professional

try using one loader:

// first frame of first scene:

var myLoader:Loader;

if(!myLoader){

myLoader = new Loader();

var urlA:URLRequest = new URLRequest("JonesPhotosA.swf");

var urlB:URLRequest = new URLRequest("JonesPhotosB.swf");

addChild(myLoader);

}

//scene where you want to load urlA

myLoader.load(urlA);  // corrected from myloader typo

// unload button

btnMainP.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_12);

function fl_ClickToGoToAndStopAtFrame_12(event:MouseEvent):void

{

myLoader.unloadAndStop();

gotoAndStop(1,"Main");

}

///// scene where you want to load urlB

myLoader.load(urlB);

// unload button

btnPhoto2.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_14);

// same as your other function so it's redundant

function fl_ClickToGoToAndStopAtFrame_14(event:MouseEvent):void

{

myLoader.unloadAndStop();

gotoAndStop(1,"Main");

}

Views

174

Likes

Translate

Translate

Report

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

Code to reset entire Stage

Explorer ,
Jul 09, 2019

Copy link to clipboard

Copied

I am a novice user.  I have a project in Animate where I have two external swfs that load.  Everything loads and unloads fine when you first click a button to load it, then unload it.  The problem is that once I load and unload, the other swf will not load.  Whichever one I click first will load and unload.  I don't know why this is happening.  I use a projector file (publish export) and this is where it doesn't work.  Everything works fine when I simply do a test scene.

So here is my question.  When I go back to the page where the buttons are, is there a code that I can put on frame one so that when the playhead reaches that frame it resets everything?  In my mind this is the solution to circumventing this issue.

I have tried to do multiple searches for such code and cannot find anything.

Paul

Adobe Community Professional
Correct answer by kglad | Adobe Community Professional

try using one loader:

// first frame of first scene:

var myLoader:Loader;

if(!myLoader){

myLoader = new Loader();

var urlA:URLRequest = new URLRequest("JonesPhotosA.swf");

var urlB:URLRequest = new URLRequest("JonesPhotosB.swf");

addChild(myLoader);

}

//scene where you want to load urlA

myLoader.load(urlA);  // corrected from myloader typo

// unload button

btnMainP.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_12);

function fl_ClickToGoToAndStopAtFrame_12(event:MouseEvent):void

{

myLoader.unloadAndStop();

gotoAndStop(1,"Main");

}

///// scene where you want to load urlB

myLoader.load(urlB);

// unload button

btnPhoto2.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_14);

// same as your other function so it's redundant

function fl_ClickToGoToAndStopAtFrame_14(event:MouseEvent):void

{

myLoader.unloadAndStop();

gotoAndStop(1,"Main");

}

Views

175

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 09, 2019 0
Adobe Community Professional ,
Jul 09, 2019

Copy link to clipboard

Copied

what code do you use to load and unload?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 09, 2019 0
Explorer ,
Jul 09, 2019

Copy link to clipboard

Copied

var myLoaderA:Loader = new Loader();

var urlA:URLRequest = new URLRequest("JonesPhotosA.swf");

myLoaderA.load(urlA);

addChild(myLoaderA);

btnMainP.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_12);

function fl_ClickToGoToAndStopAtFrame_12(event:MouseEvent):void

{

myLoaderA.load(urlA);

removeChild(myLoaderA);

SoundMixer.stopAll();

gotoAndStop(1,"Main");

}

/////Then my other one, on a separate scene is:

var myLoaderB:Loader = new Loader();

var urlB:URLRequest = new URLRequest("JonesPhotosB.swf");

myLoaderB.load(urlB);

addChild(myLoaderB);

btnPhoto2.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_14);

function fl_ClickToGoToAndStopAtFrame_14(event:MouseEvent):void

{

myLoaderB.load(urlB);

removeChild(myLoaderB);

gotoAndStop(1,"Main");

}

My main page is my landing page. When it goes back to “Main” the button to get to the scene works, but the swf won’t load.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 09, 2019 0
Adobe Community Professional ,
Jul 09, 2019

Copy link to clipboard

Copied

i assume you want to load those swfs when you go the frames that contain the code above the button codes, and the button's are supposed to unload the loaded swfs.  if that's true, use:

var myLoaderA:Loader;

if(!myLoaderA){

myLoaderA = new Loader();

var urlA:URLRequest = new URLRequest("JonesPhotosA.swf");

addChild(myLoaderA);

}

myloaderA.load(urlA);

btnMainP.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_12);

function fl_ClickToGoToAndStopAtFrame_12(event:MouseEvent):void

{

myLoaderA.unloadAndStop();

gotoAndStop(1,"Main");

}

/////Then my other one, on a separate scene is:

var myLoaderB:Loader

if(!myLoaderB){

myLoaderB = new Loader();

var urlB:URLRequest = new URLRequest("JonesPhotosB.swf");

addChild(myLoaderB);

}

myLoaderB.load(urlB);

btnPhoto2.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_14);

function fl_ClickToGoToAndStopAtFrame_14(event:MouseEvent):void

{

myLoaderB.unloadAndStop();

gotoAndStop(1,"Main");

}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 09, 2019 0
Explorer ,
Jul 09, 2019

Copy link to clipboard

Copied

Yes, that was what I intended on. Your code unloadAndStop didn’t work with my animate. It actually removed the button on my main page to get to the scene where the load swf code is. Very odd.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 09, 2019 0
Adobe Community Professional ,
Jul 09, 2019

Copy link to clipboard

Copied

there's nothing i posted that would do that.  you made some other change.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 09, 2019 0
Explorer ,
Jul 09, 2019

Copy link to clipboard

Copied

No, I only changed one line of code from removeChild(myLoaderB); to myLoaderB.unloadAndStop(); It’s the weirdest thing. And the other button was visible but inactive. Reverting those two lines brought me back to how it was.

So there is no code that brings it back to it’s launch state?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 09, 2019 0
Adobe Community Professional ,
Jul 09, 2019

Copy link to clipboard

Copied

you could load and reload your current swf using a master swf.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 09, 2019 0
Explorer ,
Jul 10, 2019

Copy link to clipboard

Copied

Not sure what that means.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 10, 2019 0
Explorer ,
Jul 10, 2019

Copy link to clipboard

Copied

My original question still seems to be where I'm at.  I had thought that the size of my Photos SWF was just too big so I had broken it into two swfs.  I have since moved it back to one swf since I was getting the same result.  The code works when published to .swf, so I know it has nothing to do with code per se.  The problem is when I publish to Win Projector to make it executable on a local machine...something I have been doing for about 13 years.  When the .exe is deployed, it gives me one launching of my swf.  On subsequent attempts it goes to the launch frame but then doesn't load.  The return to main still works, but all attempts after the first successful launch fail.  If I ESC then relaunch the .exe I can get that initial loading.  I can live with this for now, but I do these all the time and I would really like to resolve this.

In my publish settings I have tried changing the TARGET to Flash Player 30 (as well as changing it to other versions)  I have even forced updated my Flash Player even though Windows 10 claims it has it built in.  There are a few other options in the publish settings which don't work for me.

I'm led to believe the problem is within the publish step because the swf works.  I prefer the Projector mode because I want it to go full screen and the 100s of prosecutors I work with want to be able to simply launch and go.

If there was only a way for even a button to reset the .exe without closing and relaunching I could live with that.  I cannot figure out why all of a sudden this fails when previously it always worked.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 10, 2019 0
Adobe Community Professional ,
Jul 10, 2019

Copy link to clipboard

Copied

try using one loader:

// first frame of first scene:

var myLoader:Loader;

if(!myLoader){

myLoader = new Loader();

var urlA:URLRequest = new URLRequest("JonesPhotosA.swf");

var urlB:URLRequest = new URLRequest("JonesPhotosB.swf");

addChild(myLoader);

}

//scene where you want to load urlA

myLoader.load(urlA);  // corrected from myloader typo

// unload button

btnMainP.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_12);

function fl_ClickToGoToAndStopAtFrame_12(event:MouseEvent):void

{

myLoader.unloadAndStop();

gotoAndStop(1,"Main");

}

///// scene where you want to load urlB

myLoader.load(urlB);

// unload button

btnPhoto2.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_14);

// same as your other function so it's redundant

function fl_ClickToGoToAndStopAtFrame_14(event:MouseEvent):void

{

myLoader.unloadAndStop();

gotoAndStop(1,"Main");

}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 10, 2019 0
Explorer ,
Jul 10, 2019

Copy link to clipboard

Copied

THANK YOU.  Although I re-modified it to work on a single SWF, and you had a typo in your code {which I already knew} [myloader.load(urlA);....L] this worked and has restored my faith and work flow.

I also appreciate how you have patience and teach exactly where to place code.

Paul

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 10, 2019 0
kglad LATEST
Adobe Community Professional ,
Jul 10, 2019

Copy link to clipboard

Copied

you're welcome.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 10, 2019 0
Adobe Community Professional ,
Jul 09, 2019

Copy link to clipboard

Copied

There is no magic reset button. Anything that gets touched in the global state will have to be manually reset.

If you're loading directly into the root stage... don't. Load into an empty container clip that's on the stage. Even better, dynamically instantiate the container clip when you load the SWF, then destroy it when you unload it. That will get rid of any container-level contamination that the loaded SWFs are leaving behind.

And for the love of god, don't use scenes.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 09, 2019 0
Explorer ,
Jul 09, 2019

Copy link to clipboard

Copied

I have to use scenes because I came from AS2 and am not a programmer. It’s the way my brain works. I create trial exhibits and my programming is crude but I get it done, usually.

I don’t know what it means to load into an empty container clip. Can you point me to a tutorial or modify my code?

Paul

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 09, 2019 0