Jump to content
Search Community

unloading causing error

rojharris test
Moderator Tag

Recommended Posts

Hi,

So I've managed to get an external swf to load perfectly at frame 15 on my timeline like this:

 

edit: I've just found out it's an AS2 swf. Is there any way I can make it play, bearing in mind I don't need to access anything in it, then unload properly?

cheers

 

----------------------------------------------------------------------------------

stop();

var loader:SWFLoader = new SWFLoader("myswf.swf",{width:940,height:532,scaleMode:"proportionalInside",container:this,x:50,y:186,hAlign:"left",vAlign:"top"});

loader.load();

 

unloaderlogo_btn.addEventListener(MouseEvent.CLICK, fl_UnloadandgoBack);

 

function fl_UnloadandgoBack(event:MouseEvent):void

{

loader.unload();

gotoAndStop(1);

}

 

----------------------------------------------------------------------------------

 

but when I go back to frame 1, I get a 1009 null object error?

 

Frame 1 is where all my buttons to get to frame 15 are like this:

 

----------------------------------------------------------------------------------

 

import com.greensock.*;

import com.greensock.loading.*;

import com.greensock.events.LoaderEvent;

import com.greensock.loading.display.*;

 

stop();

 

 

Logo_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_6);

 

function fl_ClickToGoToAndStopAtFrame_6(event:MouseEvent):void

{

gotoAndStop(1);

}

 

button_1.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_2);

 

function fl_ClickToGoToAndStopAtFrame_2(event:MouseEvent):void

{

gotoAndStop(5);

}

 

button_2.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_3);

 

function fl_ClickToGoToAndStopAtFrame_3(event:MouseEvent):void

{

gotoAndStop(10);

}

button_3.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_4);

 

function fl_ClickToGoToAndStopAtFrame_4(event:MouseEvent):void

{

gotoAndStop(15);

}

 

----------------------------------------------------------------------------------

 

If I don't put that unload() in there then the swf stays on the stage. Any ideas why I'm getting the error? I'm not trying to communicate with the added swf, just play it, then get it off the stage when navigating back to the main menu page.

Thanks

Roger

Link to comment
Share on other sites

I'm not sure what else is going on in your FLA, but I just double-checked and SWFLoader can unload() an AS2-based swf without any problems. I was unable to replicate the issue you mentioned. Please feel free to post a simple FLA that demonstrates the issue so that I can publish it on my end and identify the issue. When you say you went back to using "plain AS3", do you mean you stopped using LoaderMax at all or that you switched your sub-swf to be AS3?

Link to comment
Share on other sites

Sure, you can e-mail your file to me if you prefer (or post it to a URL and send me the link). questions -at- greensock.com

 

As far as laughing at your code, may I cringe instead? (just kidding) You'd be surprised how much...um...creative (and I'm using that term loosely) code I see on a daily basis. Everybody is self-conscious about their code, so don't worry about it. I can be the same way.

 

It would be super helpful if you tried to minimize the code in whatever you send me. The biggest problem I get (by far) is folks not sending me anything. The second biggest problem I get is people sending me WAY too much which takes a bunch of time to parse through all the unrelated code to find the pertinent stuff. Isolating things in a separate FLA is generally a very effective troubleshooting technique for your own stuff anyway - I almost always do this before having someone else take a peek. Usually that allows me to identify the issue myself.

Link to comment
Share on other sites

The error was caused by your REMOVED_FROM_STAGE listener that tried to stop() an FLVPlayback component when it didn't exist. In other words, when you go to another frame where you have a keyframe that eliminates an object from a layer, that object no longer exists, so you cannot call stop() on it. See what I mean? The error didn't have anything to do with LoaderMax.

Link to comment
Share on other sites

Sorry, could you post your files again? I deleted them.

 

Are you saying that EVERYTHING else was EXACTLY identical except that you added a removeChild() call and it magically fixed it so that no more errors were thrown? When I deleted your line that tried to stop() the now-non-existent FLVPlayback instance, it immediately got rid of the error so that seemed pretty conclusive but maybe I missed something.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...