Skip to main content
Participating Frequently
January 1, 2008
Question

Maximum nested display containers?

  • January 1, 2008
  • 5 replies
  • 729 views
Hi,

This question is as much about best practice in building flash apps as it is about a specific problem I'm having. Is there a limit on the number of layers of display object containers that can be nested? I'm trying to build a web site, and currently, it's structured as follows: A preloader loads the main swf. The main swf displays a menu, and loads a different swf for each menu choice. One of the menu choice swf's in turn loads a swf. So, there is a maximum of 4 levels of nested display object containers in my app.

My problem is that display objects in the fourth level are not accessible from the third level. When I try to reference the fourth level .content from the third level, I get mixed results. For example, I'm able to listen for timeline-related events, like ENTER_FRAME, and to use methods like gotoAndPlay, but any reference to a display object in the fourth-level container results in a null object reference error. I tried running a function that recursively lists display objects by container, and it lists everything fine until it gets to the fourth level, at which time a null object reference error is issued. The display objects that I'm trying to reference are present in every frame of the 4th-level swf.

Is there a better way to structure a flash app than loading multiple layers of swf's? Is there a recommended maximum of or actual limitation on the number of sub-containers in an app?

--Dave
This topic has been closed for replies.

5 replies

Participating Frequently
January 1, 2008
I don't think Flash will open tommorow then unfortunately.

could you paste the code?
Participating Frequently
January 1, 2008
I was able to clean things up. The parent didn't like it if the display objects were not present in the first frame of the child, even if they weren't referenced until the child entered the frame in which they were present. So, I put all of the display objects in the first frame of the child. Then, instead of creating motion tweens on the timeline of the child, in which multiple elements were tweened separately, I tweened the whole loader object from the parent script. And the second problem was not that the new loader instance was failing with no error message; the problem was that I had nested functions, and the call to the nested function that creates the new instance was never firing. Thank you for your help!

And BTW, my web site is only about 1/4 finished. I'm going to purchase the software.
Participating Frequently
January 2, 2008
You're welcome - glad it's working now. Happy new year, and another year of the trace() statement!
Participating Frequently
January 1, 2008
The Flash CS3 IDE's cache folder is:

C:\Users\[Your Username]\AppData\Local\Adobe\Flash CS3\en\Configuration\Classes\aso

on windows vista.
Participating Frequently
January 1, 2008
Did you enter

var loader_content:Object = loader.content

or

var loader_content:Object = Object(loader.content);

before?
Participating Frequently
January 1, 2008
I've done "var loader_content:Object = loader.content" every time.

Now I'm on the next step in building my app, and after unloading the loader, a new instance of the loader fails with no error message. This is pretty much copy and paste logic from another swf that's working okay.

This is grasping at straws: does it matter that I'm on my last day of the free trial?
Participating Frequently
January 1, 2008
That's strange - a DisplayObject instance should cast to a MovieClip. Casting to an Object is perfectly fine though - probably better as

trace(typeof(loader.content));

outputs "object".
Participating Frequently
January 1, 2008
Make sure that you are only referencing loader.content when you know the content has finished loading (ie in a loadComplete function called by loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);). If this does not help could you paste the code?
Participating Frequently
January 1, 2008
In every case where I need to reference display objects in a child, I do

var loader_content:Object = loader.content

inside a loadComplete function.

Here's the code. When execution of traceDisplayList(stage) is commented out, it dies at form_swf.name_fld.setFocus(). The output of traceDisplayList(stage) is included below the code.
Participating Frequently
January 1, 2008
Try casting loader.content by changing:

var loader_content:Object = loader.content

to:

var loader_content:MovieClip = MovieClip(loader.content);