Great site. Big fan. I've posted this problem on many blogs/forums and have not yet found an answer. Any ideas?
I'm working on something; an application that loads runtime css.swf. When the loader and css.swf are online it works fine, and when the loader and the css.swf are offline it works fine. However when the loader is offline and the css.swf is online I get the following error. This situation is desired as it contracts me to use the 'live' styles while I do updates on my loader from my desktop. I can recopy my online css.swf to the offline as a workaround, but that is less desirable. I want to fix the issue so that the loader can be offline and the css.swf can be online. Typically in flash this type of operation (for everything except this css.swf workflow) works fine in my experience. As far as I can tell its because the css.swf does not 'allow' itself, security-wise to be loaded. The css.swf has no as3 scope of course (because its based in a *.css file) so I can't use Security.allowDomain('*'). Likewise it doesn't call a crossdomain automatically either.
NOTE
In my examples I've ensure that it works with both files online, both files offline, I tried various compiler options like ' -use-network=true' and various values for all 4 args in StyleManager.loadStyleDeclarations. Nothing worked yet.
USAGE
//(Local application calling server)
StyleManager.loadStyleDeclarations("
http://www.onflex.org/flexapps/applications/RuntimeCSS/style3CSS.swf");
ERROR:
Error: Unable to load style(SWF is not a loadable module):
http://www.onflex.org/flexapps/applications/RuntimeCSS/style3CSS.swf.
at <anonymous>()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\styles\StyleManagerImpl.as:858]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at ModuleInfoProxy/moduleEventHandler()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\modules\ModuleManager.as:1027]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at ModuleInfo/initHandler()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\modules\ModuleManager.as:631]
VerifyError: Error #1014: Class mx.core::FlexSprite could not be found.
[SWF] /flexapps/applications/RuntimeCSS/style3CSS.swf - 13,084 bytes after decompression
at flash.display::MovieClip/nextFrame()
at mx.core::FlexModuleFactory/deferredNextFrame()
at mx.core::FlexModuleFactory/update()
at mx.core::FlexModuleFactory/moduleCompleteHandler()
QUESTION:
Is there currently anyway to get this to work? I think not so I think it is a bug. I'll check back to this blog daily, and post the solution here if I find it elsewhere.
--
=========================
To load a module from another domain you need to "import load" the module into your security domain. The problem is Flash Player does not allow you to import load a remote swf into a local SWF file. That's explains the error in SDK-16393.
The solution is to load the module using the loadBytes() API I added in 3.2. To use loadBytes() you first load the module using an URLLoader.
// need to url load the bytes then call moduleLoader to load the bytes
var urlRequest:URLRequest = new URLRequest("http://localhost:8700/MyModule.swf");
loader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.BINARY;
When the URLLoader dispatches the complete event, you get the bytes out of the complete event and call the moduleLoader:
private function itemCompleteHandler(event:Event):void
{
loader.removeEventListener(
ProgressEvent.PROGRESS, itemHandler);
loader.removeEventListener(
Event.COMPLETE, itemCompleteHandler);
loader.removeEventListener(
IOErrorEvent.IO_ERROR, itemHandler);
loader.removeEventListener(
SecurityErrorEvent.SECURITY_ERROR, itemHandler);
//trace("loadModule event: " + event);
//ml.loadModule();
var myModuleBytes:ByteArray = ByteArray(URLLoader(event.target).data);
ml.loadModule("http://localhost:8700/MyModule.swf", myModuleBytes);
loader = null;
}
For more background, you can see the 3.2 bug where we added this loadBytes capability: https://bugs.adobe.com/jira/browse/SDK-15826 and there is an FB project with sample code attached to that bug.