Hello,
I am trying to define a global class with #initclip in Flash 8, AS2.
The global class will then load a movie into _level0, and set listeners for onLoadStart and onLoadInit.
(I want it to go into _level0 so that I can take on all the properties of the loaded movie, but still allow it to access this global class and its global variables that the parent swf created.)
It’s almost working. The loaded movie can access the global class just fine.
BUT, the problem that I am having is that the onLoadStart listener is not being called when the child movie begins to load.
(The onLoadInit listener IS being called.)
I made a MovieClip symbol, set the Linkage Identifier to “MyClass”, and checked to Export for ActionScript AND Export in first frame.
The AS inside the symbol is:
#initclip 0
if (!MyClass) {
trace("## Starting #initclip");
(_global.MyClass = function() {}).prototype;
_global.MyClass.main = function() {
trace("CALLING MyClass.main!!!");
var mc_loader = new MovieClipLoader();
var listener = new Object();
listener.onLoadStart = MyClass.onLoadStart;
listener.onLoadInit = MyClass.onLoadInit;
trace(" MyClass.onLoadStart: " + MyClass.onLoadStart);
trace(" MyClass.onLoadInit: " + MyClass.onLoadInit);
mc_loader.addListener(listener);
mc_loader.loadClip("file:///c:/movie_to_load.swf", "_level0");
};
_global.MyClass.onLoadStart = function (target) {
trace(" CALLING MyClass.onLoadStart!!!!!!!!!!!!!!!!!!!!");
};
trace(" MyClass.onLoadStart: " + MyClass.onLoadStart);
_global.MyClass.onLoadInit = function (target) {
trace(" CALLING MyClass.onLoadInit!!!!!!!!!!!!!!!!!!!!");
};
trace(" MyClass.onLoadInit: " + MyClass.onLoadInit);
trace("## Done with #initclip");
}
#endinitclip
I then have the following on the timeline:
MyClass.main();
What happens when I run the flash file, is the following:
## Starting #initclip
MyClass.onLoadStart: [type Function]
MyClass.onLoadInit: [type Function]
## Done with #initclip
CALLING MyClass.main!!!
MyClass.onLoadStart: [type Function]
MyClass.onLoadInit: [type Function]
CALLING MyClass.onLoadInit!!!!!!!!!!!!!!!!!!!!
As you can see, it detected MyClass.onLoadStart and MyClass.onLoadInit while the #initclip code was executing, and it also saw them in the call to MyClass.main.
But, as you can also see, MyClass.onLoadStart is never called as the movie is loaded. Only MyClass.onLoadInit is.
Still, the loaded movie can run MyClass.onLoadStart just fine, and get the output:
CALLING MyClass.onLoadStart!!!
So, I’m just confused as to why the MyClass.onLoadStart listener doesn’t seem to be being called when the movie is being loaded.
Any assistance is much appreciated!
Thanks!