[flexcoders] Re: Loading modules from within AIR
Hi, I thought they could be in subdirectories as well? They were in a plugins subdirectory. I've just moved them into the same folder as the app and it still doesn't work. I missed a line of code from original post: m_moduleInfo = ModuleManager.getModule(url); m_moduleInfo.load(ApplicationDomain.currentDomain); --- In flexcoders@yahoogroups.com, Alex Harui aha...@... wrote: Module must be in same dir as main SWF Alex Harui Flex SDK Developer Adobe Systems Inc.http://www.adobe.com/ Blog: http://blogs.adobe.com/aharui From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of skuteboarding Sent: Thursday, February 19, 2009 12:47 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Loading modules from within AIR Hi, I'm currently converting a Flex app to AIR and I've hit a stumbling block right at the start. When I try to load a module from disk I get the following error: SWF is not a loadable module Which after reading a couple of links I discover is a security message (normally in Flex it means you're trying to load something on a different server). In AIR how do I load a module from disk? A code example would be great. This is what I'm using currently: m_moduleInfo = ModuleManager.getModule(url); Where url is a File.url property.
[flexcoders] Re: Loading modules from within AIR
Hi, I've managed to find the problem. I was using the File.url and the File.nativePath properties to try to load module. If you change it to using just a relative path, i.e. plugins\\myplugin.swf it works just fine. Looks like it doesn't like paths like C:\... and file:///C:/... Cheers, Mark --- In flexcoders@yahoogroups.com, Alex Harui aha...@... wrote: Module must be in same dir as main SWF Alex Harui Flex SDK Developer Adobe Systems Inc.http://www.adobe.com/ Blog: http://blogs.adobe.com/aharui From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of skuteboarding Sent: Thursday, February 19, 2009 12:47 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Loading modules from within AIR Hi, I'm currently converting a Flex app to AIR and I've hit a stumbling block right at the start. When I try to load a module from disk I get the following error: SWF is not a loadable module Which after reading a couple of links I discover is a security message (normally in Flex it means you're trying to load something on a different server). In AIR how do I load a module from disk? A code example would be great. This is what I'm using currently: m_moduleInfo = ModuleManager.getModule(url); Where url is a File.url property.
RE: [flexcoders] Re: Loading modules from within AIR
Yes, it isnt' going to do the math for an absolute path to see if it is in the same security folder. You are correct that subfolders are valid as well. Alex Harui Flex SDK Developer Adobe Systems Inc.http://www.adobe.com/ Blog: http://blogs.adobe.com/aharui From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of skuteboarding Sent: Thursday, February 19, 2009 3:12 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Loading modules from within AIR Hi, I've managed to find the problem. I was using the File.url and the File.nativePath properties to try to load module. If you change it to using just a relative path, i.e. plugins\\myplugin.swf it works just fine. Looks like it doesn't like paths like C:\... and file:///C:/...file:///C:\... Cheers, Mark --- In flexcoders@yahoogroups.commailto:flexcoders%40yahoogroups.com, Alex Harui aha...@... wrote: Module must be in same dir as main SWF Alex Harui Flex SDK Developer Adobe Systems Inc.http://www.adobe.com/ Blog: http://blogs.adobe.com/aharui From: flexcoders@yahoogroups.commailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.commailto:flexcoders%40yahoogroups.com] On Behalf Of skuteboarding Sent: Thursday, February 19, 2009 12:47 PM To: flexcoders@yahoogroups.commailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Loading modules from within AIR Hi, I'm currently converting a Flex app to AIR and I've hit a stumbling block right at the start. When I try to load a module from disk I get the following error: SWF is not a loadable module Which after reading a couple of links I discover is a security message (normally in Flex it means you're trying to load something on a different server). In AIR how do I load a module from disk? A code example would be great. This is what I'm using currently: m_moduleInfo = ModuleManager.getModule(url); Where url is a File.url property.
[flexcoders] Re: Loading Modules
No sure if it covers everything you need but have alook at my post: http://blog.startup.gr/blog/Technology/Flex/_archives/2007/1/19/2664880.html leave a comment if you have any specific question. Harry
[flexcoders] Re: Loading Modules
This site seems to be pretty good: http://www.brucephillips.name/blog/index.cfm/2007/1/8/Example-Of- Using-Modules-In-Flex-201 But I am still missing something. It seems that my modules are loaded even if I don't explisitly load them. Here is my test app: ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml; initialize=onInit(event) creationComplete=onCreationComplete(event) layout=absolute mx:Script ![CDATA[ private var debug:Boolean = false; private var modLoader:ModuleLoader; private var modName:String = string_en.swf; import mx.events.ModuleEvent; import mx.modules.IModuleInfo import mx.modules.ModuleLoader; import mx.modules.ModuleManager; private function onInit(event:Event) : void { this.debug = (this.url.indexOf(-debug.swf) -1 ? true : false); /* var info:IModuleInfo = ModuleManager.getModule( getModuleName( modName ) ); info.load(); */ } private function onCreationComplete(event:Event) : void { /* modLoader = new ModuleLoader(); this.addChild(modLoader); createModule( modLoader, modName ); */ } private function getModuleName( modName:String ):String { var s:String = modName; if ( this.debug ( s.indexOf( -debug.swf ) == -1 ) ) { s = s.replace(.swf, -debug.swf); } return s; } public function createModule(m:ModuleLoader, s:String):void { if (!m.url) { m.url = getModuleName( s ); } m.loadModule(); } public function removeModule(m:ModuleLoader):void { m.unloadModule(); } private function Test_OnClick(event:Event) : void { textArea.text = string_en.Cancel; //var obj:string_en = (modLoader.child as string_en); } ]] /mx:Script mx:Text text=Text right=10 left=10 top=40 bottom=207 id=textArea/ mx:Button x=10 y=10 label=Test click=Test_OnClick(event)/ /mx:Application and here is my test module: ?xml version=1.0 encoding=utf-8? mx:Module xmlns:mx=http://www.adobe.com/2006/mxml; mx:Script ![CDATA[ public static const Ok:String = OK; // OK button public static const Cancel:String = Cancel; // Cancel button public static const Submit:String = Submit; // Submit button public function Item( name:String ) : String { return ; } ]] /mx:Script /mx:Module If you notice I have commented out the code that loads the module. Yet even then then module loads and I can get at the strings. I just want to make sure that my modules only load when asked for. Mike --- In flexcoders@yahoogroups.com, tvikatos [EMAIL PROTECTED] wrote: No sure if it covers everything you need but have alook at my post: http://blog.startup.gr/blog/Technology/Flex/_archives/2007/1/19/266488 0.html leave a comment if you have any specific question. Harry