FLEX Mobile ANDROID AIR Sandbox

Publishing Flash documents by embedding them in Flex applications
Post Reply
loicremy
Posts: 4
Joined: Wed Jan 08, 2014 5:39 am

FLEX Mobile ANDROID AIR Sandbox

Post by loicremy » Fri Jan 10, 2014 12:01 pm

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...

staff
Posts: 281
Joined: Sat Dec 15, 2007 4:48 pm

Re: FLEX Mobile ANDROID AIR Sandbox

Post by staff » Mon Jan 13, 2014 5:24 am

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.

Post Reply