I'm having a really weird problem with my server-side code when trying to use compiled versions of the files. When using the source files (.asc) everything works correctly, but when using the compiled versions of the files things get weird.
The short version is this: If I try loading a file more than once (using load()) the class defined in that file suddenly becomes inaccessable. The files protect against running the code in them more than once on their own, so there shouldn't be any conflicts there. And now the long version with code: My test has 3 files: main.asc premiere/TestBaseClass.asc premiere/TestChildClass.asc The source for the working version of the files are below. TestBaseClass is a simple base class with a single 'init' function used by the constructor. TestChildClass is a simple class that extends TestBaseClass with its own version of init. The child class does a load("premiere/TestBaseClass.asc") at the top. If that's the only place the file is loaded then it works fine. However, if I load the base class in main.asc as well then I get the following error when initializing the application in FMS: "premiere\TestBaseClass.asc: line 6: this.init has no properties" If I then remove the load() from the child class and leave it in main.asc it starts working again. Now, for a single child class this works fine. However, our code has a lot of cases where a class is extended by many other classes. Right now each of these classes do a load() of the base class at the top. Up until now we've been running the code interpreted so it's been working fine, but now that I'm trying to compile the code I'm hitting the multiple load problem. Is there any easy way to fix this problem other than changing everything in a way that prevents any file from being loaded more than once? Has anyone else seen this problem? -Andy ===============main.asc=============== //load("premiere/TestBaseClass.asc"); load("premiere/TestChildClass.asc"); // application stuff down here that doesn't matter as it's never reached ===============TestBaseClass.asc=============== try { var dummy = application.TestBaseClassLoaded(); } catch ( e ) { trace("::: Loading TestBaseClass Class :::"); function TestBaseClass() { this.init.apply(this, arguments); } TestBaseClass.prototype.init = function() { trace("TestBaseClass.init()"); } // Used to prevent this class from being loaded twice: function TestBaseClassLoaded() { return true; }; application.TestBaseClassLoaded = TestBaseClassLoaded; trace("::: LOADING ::: TestBaseClass Class loaded successfully. :::"); } ===============TestChildClass.asc=============== try { var dummy = application.TestChildClassLoaded(); } catch ( e ) { trace("::: Loading TestChildClass Class :::"); load("premiere/TestBaseClass.asc"); function TestChildClass() { this.init.apply(this, arguments); } TestChildClass.prototype = new TestBaseClass(); TestChildClass.prototype.constructor = TestChildClass; TestChildClass.superclass = TestBaseClass.prototype; TestChildClass.prototype.init = function() { TestChildClass.superclass.init.apply(this, arguments); trace("TestChildClass.init()"); } // Used to prevent this class from being loaded twice: function TestChildClassLoaded() { return true; }; application.TestChildClassLoaded = TestChildClassLoaded; trace("::: LOADING ::: TestChildClass Class loaded successfully. :::"); } _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com