header
ask question
Click here to ask Question Now Its free No registration required. Flash, Flex, Flash Media Server, ActionScript,Adobe Air. Most questions receive a response in an hour.
Manu
Points:0
Posts:0

8/9/2010 1:41:41 AM

Title: Error


I am getting this error while wrting to a file why this is happening please help.

SecurityError: fileWriteResource
at runtime::SecurityManager$/checkPrivilegeForCaller()
at flash.filesystem::FileStream/open()

The code is below.


 
              var file:File = File.applicationDirectory.resolvePath("file.txt");
             // var file:File = File.documentsDirectory.resolvePath("test.txt"); // to store in documents directory.

	           var fs:FileStream = new FileStream();
	           fs.open(file, FileMode.WRITE);
	           fs.writeUTFBytes("hello");
	           fs.close();





1
Ronald
Points: 430
Posts:0
8/9/2010 1:58:23 AM



I think you need to declare the client property for filestream and attach the metadata handler to fix this error. here is the actionscript code

var client:Object = new Object();  
client.onMetaData = function(metadata:Object):void {  
   
  }  
fs.client = client; 

2
Manu
Points: 0
Posts:0
8/9/2010 2:11:31 AM



fs.client = client; is showing an error
is there anything to import.

3
Shawn
Points: 680
Posts:0
8/9/2010 2:51:09 AM



this should work



var appDirectoryPath:File = File.applicationDirectory;
var nativePathToAppDirectory:String = appDirectoryPath.nativePath.toString();
nativePathToAppDirectory+= "file.txt";
var file:File = new File(nativePathToAppDirectory);

var fstream:FileStream = new FileStream();
fstream.open(file, FileMode.WRITE);
fstream.writeUTFBytes("My Text to be written");
fstream.close();


4
Manu
Points: 0
Posts:0
8/9/2010 3:01:28 AM



Thankyou shawn for the help
Now the error has gone,but the file is not created.
any guess.

5
Shawn
Points: 680
Posts:0
8/9/2010 4:20:38 AM



make sure your directory is not read only


Post your Reply
Name  

Email

Type your Reply or Answer

Are you human? What is 4+3 



Members Login

Email  
Password
Forgot Password





This website focus on: Flash | Flex | FMS | RED5 | WOWZA | Flash Media Server | Adobe AIR | ActionScript,Flash Solutions | Flash Question | Flash Answers | Flash Developers | Flash Problem, Flash Help, Flash bugs, Flash workaround | Flash Blog | Flex Question Answers | Flash Forum | Flex Development | Actionscript development | Flash development | Adobe AIR development
Copyright © 2008 AskMeFlash.com. All rights reserved. Privacy Policy | Terms & Conditions