View Full Version : can i attach a document class at runtime?
maloola
June 23rd, 2008, 03:46 AM
i want to load a swf into a blank document, and force the SWF to a have a document class, and i don't want to set the document class inside the file FLA, before composing it:sigh:
TheCanadian
June 23rd, 2008, 12:52 PM
nope
nikefido
June 23rd, 2008, 02:46 PM
....why?
Krilnon
June 24th, 2008, 12:00 AM
What are you trying to do? You can replace a document class instance with a loaded clip:
var s:Stage = stage;
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.IN IT, function():void {
s.removeChild(root);
s.addChild(loader.content);
});
loader.load(new URLRequest('external.swf'));
You won't have access to the stage for a little while, but otherwise you have essentially replaced the document class... though there are some other small differences.
Edit: Although, I don't think that there is really anything special about loading a movie into that position, so I'm tempted to agree with TheCanadian.
Iamthejuggler
June 24th, 2008, 04:37 AM
Isn't the document class just a quick and easy way to import and instantiate a normal AS class? I don't use it so may be wrong.
Fidodo
June 24th, 2008, 06:15 AM
No, the document class is kinda like an extension of the Stage class. Basically it is a display class that is at the very base of everything. You should use it. It helps keep your code much cleaner.
Iamthejuggler
June 24th, 2008, 06:26 AM
Ah gotcha. I don't use it because i use FlashDevelop rather than Flash. But i do see the benefit of using it now you've explained the point.
maloola
June 26th, 2008, 04:03 AM
nikefido & Krilnon - my loaded swf needs to be code free, and i don't want the designers to add a document class before composing the fla. :pa:
first i wanted to force the swf by adding one, but apparently this won't work. i created the old document class instance from the main application and than loaded the code free swf from it, using the swf's reference instead of using "this" :devious:
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.