The definition doesn't exist at static initialization time so I think that's expected behavior. You'll see all of our code doing a null test then creating the instance inside of getInstance()
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of cadisella Sent: Tuesday, December 09, 2008 1:50 PM To: [email protected] Subject: [flexcoders] inner classes and static initialization I'm having a strange problem with the use of an inner class and I wanted to see if anyone thought that this was a bug or the correct behavior. Here's my test that shows the problem: package { use namespace MyNamespace; public class InternalClassTest { public static const mtInstance:InternalClassTest = new InternalClassTest(); public static function getInstance():InternalClassTest { return mtInstance; } MyNamespace var mtInternalClass:MyInternal; ! public function InternalClassTest() { mtInternalClass = new MyInternal(); } } } use namespace MyNamespace; internal class MyInternal { } The existence of the static constant that calls the InternalClassTest constructor is where the issue lies. I get this error: TypeError: Error #1007: Instantiation attempted on a non-constructor. at InternalClassTest()[C:\5DCVS_Flex\Testing\src\InternalClassTest.as:16] at InternalClassTest$cinit() at! global$ init()[C:\5DCVS_Flex\Testing\src\InternalClassTest.as:5] at TestApp()[C:\5DCVS_Flex\Testing\src\TestApp.as:35] at Testing()[C:\5DCVS_Flex\Testing\src\Testing.mxml:0] at _Testing_mx_managers_SystemManager/create() at mx.managers::SystemManager/initializeTopLevelWindow()[E:\dev\3.1.0\frameworks\projects\framework\src\mx\managers\SystemManager.as:2454] at mx.managers::S! ystemManager/http://www.adobe.com/2006/flex/mx/internal::docFrameHandler()[E:\dev\3.1.0\frameworks\projects\framework\src\mx\managers\SystemManager.as:2344] If I remove the call to new MyInternal() from the constructor of InternalClassTest, then I can get the same functionality by implementing the internal class in the following way: internal class MyInternal { { InternalClassTest.getInstance().mtInternalClass = new MyInternal(); ! ; & nbsp; } } So the problem seems to be that the MyInternal class has not been initialized when accessing the InternalClassTest class through a static method. The solution is kind of a pain, and certainly not exactly intuitive. From what I can tell it means that no singleton would be able to access an internal class through its constructor. This is in Flex Builder 3.0.1. with the Flex 3.1 SDK. Thanks for any thoughts. Dale

