browseForSave error in air/as3

Hi,

I’m getting the following error;

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

When I use the following code;

	 
//browse code i'm having trouble with starts here at the end of one of my functions.

       var appDir:File = File.applicationDirectory;
			try
			{
			    appDir.browseForSave("Save As");
		    	appDir.addEventListener(Event.SELECT, saveData);
			}
			catch (error:Error)
			{
			    trace("Failed:", error.message);
			}

		}; // end function saveXML
			
			
		function saveData(myE:Event):void 
		{
			var outputString:String = new String(ttFrame_xml.toString());
			var newFile:File = myE.target as File;
				
			if (!newFile.exists)
			{
				var stream:FileStream = new FileStream();
				stream.open(newFile, FileMode.WRITE);
				stream.writeUTFBytes( outputString );
				stream.close();
			}
		};


This is taken almost straight from the adobe pages (AIR / flash.filesystem / browseforSave )

I cannot see where the problem is. If anyone else can I’d appreciate it.

Thanks