I am trying to put some components in a module and one of them which
uses an HSlider is causing a crash.  The module loads fine but when I
try to add the component with addChild it crashes with:
TypeError: Error #1007: Instantiation attempted on a non-constructor.

Here is the main application:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="vertical"
        creationComplete="onCreationComplete()">
        <mx:Script>
                <![CDATA[
                        import mx.modules.IModuleInfo;
                        import mx.modules.ModuleManager;
                        
                        private var moduleRef:IModuleInfo;
                        private var module:MyModule;
                        
                        private function onCreationComplete():void
                        {
                                moduleRef = 
ModuleManager.getModule("MyModule.swf");
                                moduleRef.addEventListener("ready", 
onModuleLoaded);
                                moduleRef.load();
                        }
                        
                        private function onModuleLoaded(event:Event):void
                        {
                                module = moduleRef.factory.create() as MyModule;
                                myPanel.addChild(module.slider);
                        }
                ]]>
        </mx:Script>
        
        <mx:Panel id="myPanel"
                title="Module Test Application" 
                width="400" height="400">
                <mx:Label text="Hello World"/>
        </mx:Panel>
        
</mx:Application>

Here is the Module:
package
{
        import mx.modules.ModuleBase;
        import mx.controls.sliderClasses.Slider;
        
        public class MyModule extends ModuleBase
        {
                public var slider:Slider;
                
                public function MyModule()
                {
                        slider = new Slider();
                }
        }
}

Reply via email to