Today I upgraded from Flex Builder 3 (Flex 3 SDK) to Flash Builder 4. I am new to Flex programming, and am still learning the Flex basics and Flex lifecycle. When I imported my project into Flash Builder 4, recompiled (without errors), and ran my project, I received the following error:
TypeError: Error #1007: Instantiation attempted on a non-constructor.
at mx.controls::VideoDisplay/createBorder()[E:\dev\4.x\frameworks\projects\framework\src\mx\controls\VideoDisplay.as:1800]
at mx.controls::VideoDisplay/createChildren()[E:\dev\4.x\frameworks\projects\framework\src\mx\controls\VideoDisplay.as:1484]
at mx.core::UIComponent/initialize()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\UIComponent.as:7349]
at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\UIComponent.as:7241]
at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\Container.as:3972]
at mx.core::Container/addChildAt()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\Container.as:2616]
at mx.core::Container/addChild()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\Container.as:2534]
at mx.core::Container/createComponentFromDescriptor()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\Container.as:4392]
at mx.core::Container/createComponentsFromDescriptors()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\Container.as:4181]
at mx.core::Container/createChildren()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\Container.as:3187]
at mx.core::UIComponent/initialize()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\UIComponent.as:7349]
at mx.core::Container/initialize()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\Container.as:3129]
at VideoModule/initialize()
at ModuleLoader_modified/handleModuleReady()[/Users/briankiefer/Dropbox/Duke/adstream/workspace/sidewalk-alpha/ModuleLoader_modified/src/ModuleLoader_modified.mxml:88]
at ModuleLoader_modified/__adLoader_ready()[/Users/briankiefer/Dropbox/Duke/adstream/workspace/sidewalk-alpha/ModuleLoader_modified/src/ModuleLoader_modified.mxml:101]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\UIComponent.as:12528]
at mx.modules::ModuleLoader/moduleReadyHandler()[E:\dev\4.x\frameworks\projects\framework\src\mx\modules\ModuleLoader.as:462]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at ModuleInfoProxy/moduleEventHandler()[E:\dev\4.x\frameworks\projects\framework\src\mx\modules\ModuleManager.as:1168]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at ModuleInfo/readyHandler()[E:\dev\4.x\frameworks\projects\framework\src\mx\modules\ModuleManager.as:812]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::FlexModuleFactory/update()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\FlexModuleFactory.as:433]
at mx.core::FlexModuleFactory/docFrameHandler()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\FlexModuleFactory.as:582]
at mx.core::FlexModuleFactory/docFrameListener()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\FlexModuleFactory.as:126]
The error disappeared when I enabled "Use Flex 3 compatibility mode" under Project | Properties | Flex Compiler options. I want to make my project Flex 4 compatible. I could not find an answer from Stack Overflow or Adobe. Any idea what is causing this error? It occurs on the line when I call initialize() on a custom MXML module.
private var vm:VideoModule;
...
vm = VideoModule(moduleLoader.child); // moduleLoader's child is a VideoModule; just casting it
vm.initialize(); // error is here