[Flashcoders] AS3 - getDefinitionByName and external swfs
Hello, I have some classes with a lot of code that I may or may not need depending on the situation. These classes all extend a superclass that I refer to in my main application. My ideal would be to define subclasses only in external swfs, load the swfs and then instantiate the classes via a string passed to getDefinitionByName so that the subclasses are not included in the main application. So the model is: Main.swf / Main.as contains SupClass.as but does not have references to Subclass1 or Subclass2 Subclass1.swf / Subclass1.as Subclass2.swf / Subclass2.as Main.as decides it wants Subclass1, loads Subclass1.swf, load inits and completes, Main.as tries to instantiate Of course, when I try this, I get the typical ReferenceError: Error #1065: Variable Subclass1 is not defined. Is there any way that anyone knows of to instantiate a class this way? I would love to keep it out of the Main.swf. Here seems to be a well phrased argument that seems to insist that the class always be included in the swf that is trying to instantiate (and thus all the code will be duplicated). http://nwebb.co.uk/blog/?p=186 Thanks dudes and dudettes, -jonathan -- -jonathan howe ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] AS3 - getDefinitionByName and external swfs
It definitely works (to do as you describe). I think you need to take a good look at the ApplicationDomain class - make sure that the loaded SWF is in the same application domain as your loading SWF, and it should all be fine. Alternatively, you can specifically query the child's applicationDomain via the loader - caling getDefinitionByName() on just that applicationDomain. HTH, Ian On Sun, Feb 15, 2009 at 3:08 PM, jonathan howe jonathangh...@gmail.com wrote: Hello, I have some classes with a lot of code that I may or may not need depending on the situation. These classes all extend a superclass that I refer to in my main application. My ideal would be to define subclasses only in external swfs, load the swfs and then instantiate the classes via a string passed to getDefinitionByName so that the subclasses are not included in the main application. So the model is: Main.swf / Main.as contains SupClass.as but does not have references to Subclass1 or Subclass2 Subclass1.swf / Subclass1.as Subclass2.swf / Subclass2.as Main.as decides it wants Subclass1, loads Subclass1.swf, load inits and completes, Main.as tries to instantiate Of course, when I try this, I get the typical ReferenceError: Error #1065: Variable Subclass1 is not defined. Is there any way that anyone knows of to instantiate a class this way? I would love to keep it out of the Main.swf. Here seems to be a well phrased argument that seems to insist that the class always be included in the swf that is trying to instantiate (and thus all the code will be duplicated). http://nwebb.co.uk/blog/?p=186 Thanks dudes and dudettes, -jonathan -- -jonathan howe ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] AS3 - getDefinitionByName and external swfs
Cool, thanks Ian, I had assumed that the currentDomain would be the default (or at least the related behavior). I read this from the documentation: By putting the loaded SWF file in the same application domain, you can access its classes directly. This can be useful if you are loading a SWF file that contains embedded media, which you can access via their associated class names, or if you want to access the loaded SWF file's methods... That's exactly the kind of @#! I'm talkin' about! So I will try using Loader with the ApplicationDomain.currentDomain parameter. -jonathan On Sun, Feb 15, 2009 at 10:33 AM, Ian Thomas i...@eirias.net wrote: It definitely works (to do as you describe). I think you need to take a good look at the ApplicationDomain class - make sure that the loaded SWF is in the same application domain as your loading SWF, and it should all be fine. Alternatively, you can specifically query the child's applicationDomain via the loader - caling getDefinitionByName() on just that applicationDomain. HTH, Ian On Sun, Feb 15, 2009 at 3:08 PM, jonathan howe jonathangh...@gmail.com wrote: Hello, I have some classes with a lot of code that I may or may not need depending on the situation. These classes all extend a superclass that I refer to in my main application. My ideal would be to define subclasses only in external swfs, load the swfs and then instantiate the classes via a string passed to getDefinitionByName so that the subclasses are not included in the main application. So the model is: Main.swf / Main.as contains SupClass.as but does not have references to Subclass1 or Subclass2 Subclass1.swf / Subclass1.as Subclass2.swf / Subclass2.as Main.as decides it wants Subclass1, loads Subclass1.swf, load inits and completes, Main.as tries to instantiate Of course, when I try this, I get the typical ReferenceError: Error #1065: Variable Subclass1 is not defined. Is there any way that anyone knows of to instantiate a class this way? I would love to keep it out of the Main.swf. Here seems to be a well phrased argument that seems to insist that the class always be included in the swf that is trying to instantiate (and thus all the code will be duplicated). http://nwebb.co.uk/blog/?p=186 Thanks dudes and dudettes, -jonathan -- -jonathan howe ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- -jonathan howe ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] AS3 Fullscreen mode w/ Windows Projectors
Hello, According to docs Full-screen mode is always permitted in the stand-alone player or in a projector file. Yet I get a SecurityError: Error #2152 when I call stage.displayState = StageDisplayState.FULL_SCREEN; from a projector. But I don't get it when I use the old fscommand method of going fullscreen. For projectors, shouldn't the mouseevent-click security requirement be waived in order to automatically go fullscreen? Why would it work with fscommand but not the official way, displayState? Anyone do this regularly who has a hint? Should I just be glad fscommand works? -jonathan -- -jonathan howe ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders