Over 10 years of community discussion and knowledge are maintained here as a read-only archive.
hi! im finding trouble in creating the multicore mvc pipes structure in flash as3 only...can you help me..do you have a sample as3 sample program that we could see..with no flex..we would really appreciate it..
/** * ... * @author Jason MacDonald (Jason.MacDonald@vfmii.com) */ public class ModuleLoader extends Sprite{ public static const READY:String = "READY"; private var _module:ILoadableModule; public var _moduleVo:LoadableModuleVo; public function ModuleLoader() { } public function load(moduleVo:LoadableModuleVo):void { var loader:Loader = new Loader(); _moduleVo = moduleVo; loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onLoaded); loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,onIOError); loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,onProgress); var loaderContext:LoaderContext = new LoaderContext(true); loader.load(new URLRequest(moduleVo.url), loaderContext); } protected function removeListeners(loader:LoaderInfo):void { loader.removeEventListener(Event.COMPLETE,onLoaded); loader.removeEventListener(IOErrorEvent.IO_ERROR,onIOError); loader.removeEventListener(ProgressEvent.PROGRESS,onProgress); } protected function onLoaded(event:Event):void { var loaderInfo:LoaderInfo = event.target as LoaderInfo; _module = loaderInfo.content as ILoadableModule; removeListeners(loaderInfo); dispatchEvent(new Event(READY)); } protected function onIOError(event:IOErrorEvent):void { //do something } protected function onProgress(event:Event):void { //do something } public function get moduleVo():LoadableModuleVo { return _moduleVo; } public function set moduleVo( value:LoadableModuleVo ):void { _moduleVo = value; } public function get module():ILoadableModule { return _module; } public function set module( value:ILoadableModule ):void { _module = value; } }
/** * ... * @author Jason MacDonald (Jason.MacDonald@vfmii.com) */ public class LoadableModuleVo { private var _name:String; private var _url:String; private var _version:String; public function LoadableModuleVo() { } public function get name():String { return _name; } public function set name( value:String ):void { _name = value; } public function get url():String { return _url; } public function set url( value:String ):void { _url = value; } public function get version():String { return _version; } public function set version( value:String ):void { _version = value; } }
/** * The interface definition for a loadable Module. * * <P>The only requirement of our [dynamically] loadable * module is that it implements this interface so we can get * a unique ID back from the module</P> */ public interface ILoadableModule { function getID():String; }
public class ModuleLoaderProxy extends Proxy implements IProxy { public static const LOAD_MODULE:String = 'mlLoadModule'; public static const UNLOAD_MODULE:String = 'mlUnloadModule'; public static const MODULE_LOADED:String = 'mlModuleLoaded'; public static const MODULE_FAILED:String = 'mlModuleFailed'; public static const MODULE_PROGRESS:String = 'mlModuleProgress'; public static const NAME:String = "ModuleLoaderProxy"; /** Constructor **/ public function ModuleLoaderProxy(data:Object = null){ super (NAME, data); } public function loadModule(moduleVo:LoadableModuleVo):void { var loader:ModuleLoader = new ModuleLoader(); loader.addEventListener(ModuleLoader.READY, onLoaded); loader.addEventListener(IOErrorEvent.IO_ERROR, onIOError); loader.load(moduleVo); } protected function onLoaded(event:Event):void { var moduleLoader:ModuleLoader = event.target as ModuleLoader; var module:ILoadableModule = moduleLoader.module; var moduleVo:LoadableModuleVo = moduleLoader.moduleVo; sendNotification(MODULE_LOADED, module, moduleVo.name); removeListeners(moduleLoader); } protected function onIOError(event:IOErrorEvent):void { var moduleLoader:ModuleLoader = event.target as ModuleLoader; var module:ILoadableModule = moduleLoader.module; sendNotification(MODULE_FAILED, module, event.text); removeListeners(moduleLoader); } protected function removeListeners(moduleLoader:ModuleLoader):void { moduleLoader.removeEventListener(ModuleLoader.READY, onLoaded); moduleLoader.removeEventListener(IOErrorEvent.IO_ERROR, onIOError); } protected function onProgress(event:Event):void { //sendNotification(MODULE_PROGRESS, module); }