views:

32

answers:

2

Hello,

I am using the Loader class to load 3 external swfs:

  1. sharedTopics.swf (does not have a document class)
  2. fonts.swf (document class is FontManager)
  3. main.swf (document class is Main)

The same loader is used to load all 3 assets.

__assetLoader = new Loader(); 
var urlReq:URLRequest = new URLRequest(target.path);
__assetLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, this.preloadProgress);
__assetLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, this.assetCompleteHandler); 
__assetLoader.contentLoaderInfo.addEventListener(Event.INIT, this.assetInitHandler); 
__assetLoader.load(urlReq);

In the complete handler, I add the loader content to a movie clip then trace out a variable:

var swf:DisplayObject = __assetLoader.content;
Debug.doTrace("Shell:: assetCompleteHandler():: content " + swf);
__app.addChild(MovieClip(swf));

When the sharedTopics, fonts and main swfs (respectively) are loaded I get the following trace statements:

Shell:: assetInitHandler():: evt.currentTarget.content [object MovieClip]
Shell:: assetInitHandler():: evt.currentTarget.content [object FontManager]
Shell:: assetInitHandler():: evt.currentTarget.content [object Main__Preloader__]

I would expect that the last trace statement would look similar to '[object Main]' which would be the name of the document class however, instead the content is the loader. Any ideas as to why this is happening?

In a later function I try to call the init function of the Main class and get the following error:

Error #1069: Property init not found on classes.Main__Preloader__ and there is no default value.

I hope this is explained clearly.

Thanks in advance,

Mike

A: 

It looks like main.swf wasn't intended to be loaded indirectly as you're attempted to do. zeh has a point , Main could be a child of the SWF...
If this is the case (and it looks like it is), you should have a look at Main.as , find the instance of Main_Preloader and retrieve the url it is loading and load this instead... or try to simply bypass Main_Preloader or/and re-implement it within your AssetLoading class.

PatrickS
Thanks for you responses. I'm not entirely sure how Main could be a child of the swf, since the document class for the main.fla is 'Main'. One thing I want to point out, is I do not define 'Main__Preloader__' and only happens when loading the Main. The main.fla does contain imported assets from the RSL (sharedTopics). Perhaps this is why. I will also mention I am using CS5 if that sheds light on any kind of oddity.
mike
well i've got an answer and wanted to share...the problem was that I was using a TLFTextField and had to change the 'Default Linkage' found in Actionscript 3.0 Settings > Library Path, to 'Merged into code'. Previously the default linkage was 'Runtime Shared Library' and therefore the 'main' was using the predefined 'Preloader SWF' to load the external libraries.
mike
well done! ;) thanks for the info , may come handy...
PatrickS
+2  A: 

The culprate was the TLFTextField. By default, in CS5, the 'Library path' (found in ActionScript3.0 Settings > Library Path) items are set to be Runtime Shared Libraries and use a default preloader, so by changing the 'Default Linkage' to 'Merged into code' you do not have to worry about externally loading these libraries...

mike
Wow. Didn't know that.
Subb