History | Log In     View a printable version of the current page.  
Issue Details (XML)

Key: SDK-15393
Type: Bug Bug
Status: Closed Closed
Resolution: External
Priority: None None
Assignee: Joan Lafferty
Reporter: Samuel Asher Rivello
Votes: 2
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
Flex SDK

Enable Local App to load RunTime CSS.swf from Server

Created: 04/25/08 06:27 PM   Updated: 05/27/09 02:54 PM
Component/s: Runtime CSS
Security Level: Public (All JIRA Users )

Severity: Usability Issue
Reproducibility: Every Time
Discoverability: Medium
Found in Version: SDK Flex 3 (Released)
Affected OS(s): All OS Platforms - All
Steps to Reproduce:
   
    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.

--
Language Found: English
Bugbase Id: none
Regression: No
QA Owner: Joan Lafferty
Resolved by: Joan Lafferty
Participants: Joan Lafferty, Samuel Asher Rivello and Tom Schober
Browser: Firefox 2.x


 All   Comments      Sort Order:
Joan Lafferty - [01/23/09 04:05 PM ]
Sam, I checked with one of our developers and here is the solution that he has offerred. The limitation is a part of the player's security model.

=========================

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.

Tom Schober - [05/27/09 02:54 PM ]
I am attempting to load a style SWF from a different domain (because we're using a CDN). So if I understand this correctly... You want us to call loadStyleDeclarations after all this, which will, in essence re-download the swf, but now be allowed into the SecurityDomain? Sometimes this doesn't work and I'm not getting any exceptions. It seems like a timing issue and it's inconsistent.

private var _styleUrlLoader : URLLoader = new URLLoader();
private var _styleModuleLoader : ModuleLoader = new ModuleLoader();

private function initialize() : void
{
_styleModuleLoader.addEventListener(ModuleEvent.READY, onStyleModuleLoaderReady);

_styleUrlLoader.addEventListener(Event.COMPLETE, onStyleLoaderComplete);
_styleUrlLoader.dataFormat = URLLoaderDataFormat.BINARY;
_styleUrlLoader.load(new URLRequest("http://path.to.my.swf"));
}

private function onStyleLoaderComplete(event : Event) : void
{
_styleUrlLoader.removeEventListener(Event.COMPLETE, onStyleLoaderComplete);

var moduleBytes : ByteArray = ByteArray(URLLoader(event.target).data);

_styleModuleLoader.loadModule(_styleUrl, moduleBytes);

_styleUrlLoader = null;
}

private function onStyleModuleLoaderReady(event : ModuleEvent) : void
{
// Now that the module is in the security domain it we can load from this url
StyleManager.loadStyleDeclarations(_styleUrl);
}