Using ModuleManager to load the modules allows me to access the
Interface methods(in this case 'selectedMedia').  It seems that
casting the child within ModuleLoader as an ISoundPlayer interface (in
my example) always reports the child as NULL when loaded.   However,
casting the loaded module as a DisplayObject gives me access to the
methods.  


Example:

private var info:IModuleInfo;
public var sm:Object;

private function initComponent():void
{
   info = ModuleManager.getModule("SoundPlayer.swf");                     
info.addEventListener(ModuleEvent.READY,onLoadComplete)           
info.addEventListener(ModuleEvent.ERROR,onLoaderError);
   info.load();
}

private function onLoadComplete(event:ModuleEvent):void 
{
   trace("Completed and ready");
   sm = info.factory.create() as DisplayObject;
   soundPlayer.addChild(sm as DisplayObject); // add to display

   if( sm != null ) {
       trace("weeee, its ready");
       sm.selectedMedia = _mp3URL; //the function in the interface
   } else {
        trace("sound player not ready");
   }
}                       
                        
private function onLoaderError(event:ModuleEvent):void 
{
   trace("Problem " + event.errorText);
}

<mx:Canvas id="soundPlayer" width="100%" height="100%"/>




// Interface

package com.custom.interfaces
{
        import flash.events.IEventDispatcher;
        
        public interface ISoundPlayer extends IEventDispatcher
        {
                function set selectedMedia(mp3URL:String):void;
        }
}


- mr



--- In flexcoders@yahoogroups.com, "kristian_wright2002"
<[EMAIL PROTECTED]> wrote:
>
> *BUMP*
> 
> Anyone have any ideas?  I still haven't found a solution...
> 
> K.
>


Reply via email to