Adobe Integrated Runtime (AIR) for JavaScript Developers Pocket Reference

(nextflipdebug5) #1

76 | Chapter 4: AIR Mini-Cookbook


win.stage.scaleMode = window.runtime.flash.display.
StageScaleMode.NO_SCALE;
win.stage.align = window.runtime.flash.display.
StageAlign.TOP_LEFT;
win.stage.addChild( control );
}
</script>

</head>
<body onload="doLoad( )">

</body>
</html>

File API


Writing Text to a File from a String


Problem


Auser has made changes to textual content in the applica-
tion, which the user wants to save to disk for offline access.


Solution


Writing text can be accomplished through theFileand
FileStream classes that are part of AIR.


Discussion


Before any reading or writing takes place to disk, a reference
to a file or directory must first exist in the application. Afile
reference can be established in a number of ways, including
programmatic manipulation and user selection. Both of these
are accomplished by using theFileclass. TheFileclass also
contains static properties that point to common locations on
the operating system. These locations include the desktop
directory, user directory and documents directory:

Free download pdf