Flex create a text and writes the information

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

Flex create a text and writes the information as in the following example:

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" 
	layout="horizontal" fontSize="12"
    creationComplete="getStudentInfo('helloworld')">
    
    <mx:Script>
    	<![CDATA[
    	        import mx.controls.Alert;
    		import flash.filesystem.File;
    		import flash.filesystem.FileMode;
    		import flash.filesystem.FileStream;
    		
    		private function getStudentInfo(str:String):void{
    			/*The value of File.applicationDirectory.nativePath is: 
    			     C:\Documents and Settings\a\My Documents\Flex Builder 3\readTxtDemo\bin-debug
    			*/
                var file:File = new File("D:\\dataTest\\student.txt");    //If no such file will create it
                var stream:FileStream = new FileStream();    //Create a FileStream object
                stream.open(file, FileMode.WRITE);    //Use the FileStream object to open the File object is read-only
                stream.writeUTFBytes(str);
                stream.close();    //Close the FileStream object
            }
    	]]>
    </mx:Script>
    
    <mx:Panel title="To read data from a file" verticalAlign="middle" horizontalAlign ="center" width="90%" height="90%">
        <mx:TextArea id="txtTextAreaID"  width="300" height="200" borderColor="#FF0000" borderThickness="5"/>
    </mx:Panel>
    
</mx:WindowedApplication>


 

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Mandel at December 25, 2013 - 6:33 AM