0
votes

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

2
How was Main created? Apparently it's using the two-frame trick for compiling SWFs, which is what's usually done when using Flex or by using the SDK -frame command line argument. In that case, you'd have to wait for the main SWF to be INITed too, or somehow find out when is it fully available (fully loaded). It could be that Main is not the SWF but rather a child of it. - zeh
Thanks for the reply the main.fla attaches the document class and inside the fla there isn't any AS. The class does contain quite a substantial amount of AS and package imports etc... I'm not familiar with the 'two-frame' trick as you mention. Also, I just added a recursive function which tries to call the init function which catches the error of init not exitsting on 'Main__Preloader__' and recurses. No such luck. - mike

2 Answers

3
votes

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

0
votes

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.