Jump to content
Search Community

SWF Loader trouble. Buttons can't load from one loader into another

ngrinchenko test
Moderator Tag

Recommended Posts

Here is my set up.

I have 3 stages (pages) on my main time line.

On Stage 1 there is a button which leads to Stage 2 and loads an SWF file into a loader located on Stage 2. Loaded SWF file has button which leads to stage 3 and loads another SWF which has the button which is supposed to lead to stage 2 and load an SWF file into the loader located on the Stage 2.

Here is my problem. The button from the SWF file loaded on Stage 3 doesn't work in the real (non test) version.

I made a test (attached) and everything works, however in the real world with other items something throws off the code.

Here is the error I get in the Output panel:

 

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

at acolyte51a_AppsPopUpsThumbs_fla::mainsite_mc_2/frame72()[acolyte51a_AppsPopUpsThumbs_fla.mainsite_mc_2::frame72:206]

at flash.display::MovieClip/gotoAndPlay()

at ButterflyGlow_fla::MainTimeline/onclickSumix32PopUp()

 

where line 206 refers to this line of code:

holderMovieClip.holderMovieClip_Bckgrnd.visible = false;

 

It seems to me that I get this error because my buttons work through SWF loaded. If I am mistaken in my assumption as to why the code gives me an error - I understand that it may be not a greensock related issue.

Link to comment
Share on other sites

When you load a swf or image into another movieclip, whatever was inside the parent movieclip gets removed as soon as the new content is loaded.

 

holderMovieClip contains holderMovieClip_bckgrnd.

 

When you load RedSWF2 (or any other swf) into holderMovieClip then holderMovieClip_bckgrnd disappears. That is why holderMovieClip.holderMovieClip_Bckgrnd is null when you go back to stage 2.

 

The solution is to put ANOTHER clip inside HolderMovieClip that you will load your external swfs into.

 

Your SWFLoader will then use

 

container:HolderMovieClip.myNewClip (or similar)

Link to comment
Share on other sites

In my set up I have around 75 swf files which load into that loader from other pages. (this loader is designed to be a pop up window for larger files)

If I follow your suggestion it means I have to have 75 other unique movie clips inside the HolderMovieClip in order to load each individual swf. Did I understand you correctly?

 

P.S. Why does the same set up works in my sample file and I don't have to put another movie clip inside the HolderMovieClip?

Link to comment
Share on other sites

Actually, I mis-spoke. Since you are using SWFLoader, the swf is loaded into a ContentDisplay Sprite and that Sprite is added to the container without destroying other assets in the container.

I don't know where my head was last night.

 

Still, from the error you are getting, its reasonable to imagine that when your code is running that holderMovieClip_bckgrnd is not present, (and thus the null object error).

 

Since your example doesn't replicate the error, it is very difficult to understand why the error is happening.

 

My apologies about the bad advice earlier.

Link to comment
Share on other sites

Hi Carl,

You help me a lot at various times, so I greatly appreciate your advice.

 

My trouble file is my main flash file which exceeds the 500K limit I can load up on the forums.

I'll keep on trying to assemble a test file see if I get any errors. Very strange that I do the same set up on the test file and main file and test file comes back clean.

Is it possible some other code interferes with SWF Loader code?

The only other thing I may think of is that I use the same Symbol for the holderMovieClip.holderMovieClip_Bckgrnd and assign it different instance name on each page. I probably have about 5 swf loaders on my site. This one is the only one to which I load from two different pages into the same loader.

Perhaps I will construct an additional SWF loader just for this page. This way it is completely new and may be will be free of errors.

 

In any case I am very thankful for all your help.

 

Happy New Year to you!

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...