Page 1 of 1

FLEX Mobile ANDROID AIR Sandbox

Posted: Fri Jan 10, 2014 12:01 pm
by loicremy
I again,


I'm working on an application for MAC/WINDOWS/ANDROID platform.

The goal of the app is to display many documents (PDF converted in P2F) in a frame inside application screen.

User can choice in differents documents to see. The documents files are downloaded in cryped(AES) mode.

At user demand, the crypted file is decrypted on the fly and written in the AIR application directory . After that , I use the 'source' property of P2F member and the document is visible.

On MAC or WINDOWS application , everything runs well.

My problem appear with ANDROID AIR's security management.

1) I don't know how to load a swf file elsewhere from application directory to P2F (sandbox violation error).
2) I don't know how to write/copy a file in the application directory (readonly directory).

With theses 2 points, I'm stuck !!


Thank you in advance for ideas or advices !

Loïc

PS : For now, I have decided to not include IOS in this development, due to swf loading limitation...

Re: FLEX Mobile ANDROID AIR Sandbox

Posted: Mon Jan 13, 2014 5:24 am
by staff
1. Try to load a document not from a file in your application directory but from a ByteArray object. This way you will circumvent sandbox restrictions:

Code: Select all

			private function loadSwfApplication():void {
				var loader:URLLoader=new URLLoader();				
				loader.dataFormat=URLLoaderDataFormat.BINARY;
				loader.addEventListener(Event.COMPLETE, onSWFLoaded);
				
				loader.load(new URLRequest("http://mysite.com/sample.swf"));
			}
			private function onSWFLoaded(e:Event):void {
				var loader:URLLoader=URLLoader(e.target);
				loader.removeEventListener(Event.COMPLETE, onSWFLoaded);
				
				var context:LoaderContext=new LoaderContext();
				context.allowLoadBytesCodeExecution=true;
				
				doc.loaderContext = context;
				
				doc.source=loader.data;
			}
Here doc refers to a Print2FlashDoc3 Flex component instance. This way you also won't need to save documents to files.

2. The application directory is read-only by design (see this help topic: http://help.adobe.com/en_US/FlashPlatfo ... nDirectory). You should use another directory, e.g. application's private storage directory which reference you can get with applicationStorageDirectory property of File class.