Last active
July 29, 2016 01:12
-
-
Save marchbold/2a0c2108a7e8d5a27b0b96fe8bf10971 to your computer and use it in GitHub Desktop.
Create a document using the Cloud Storage ANE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var document:Document = new Document(); | |
| document.filename = "uniqueFilename.txt"; // Must be unique in the container | |
| document.data = new ByteArray(); | |
| document.data.writeUTFBytes( "TEST SOME STRING WRITING" ); // Some test data | |
| CloudStorage.service.documentStore.addEventListener( DocumentEvent.SAVE_COMPLETE, createCompleteHandler ); | |
| CloudStorage.service.documentStore.addEventListener( DocumentEvent.SAVE_ERROR, createErrorHandler ); | |
| CloudStorage.service.documentStore.saveDocument( document ); | |
| ... | |
| private function createCompleteHandler( event:DocumentEvent ):void | |
| { | |
| trace( "document create complete" ); | |
| CloudStorage.service.documentStore.removeEventListener( DocumentEvent.SAVE_COMPLETE, loadCompleteHandler ); | |
| CloudStorage.service.documentStore.removeEventListener( DocumentEvent.SAVE_ERROR, loadErrorHandler ); | |
| } | |
| private function createErrorHandler( event:DocumentEvent ):void | |
| { | |
| trace( "document create error" ); | |
| CloudStorage.service.documentStore.removeEventListener( DocumentEvent.SAVE_COMPLETE, loadCompleteHandler ); | |
| CloudStorage.service.documentStore.removeEventListener( DocumentEvent.SAVE_ERROR, loadErrorHandler ); | |
| } | |
| // com.distriqt.CloudStorage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment