Actionscript 3 AS3/AIR-创建纯文本文件?

Actionscript 3 AS3/AIR-创建纯文本文件?,actionscript-3,file,air,plaintext,Actionscript 3,File,Air,Plaintext,是否可以使用AS3或AIR创建纯文本文件 示例:我想创建一个名为“MyTextFile.txt”的纯文本文件,使其包含“这是我的文本文件”的文本,并将其保存到我的桌面 另一个选择是让文件已经存在于目录中,因此我只需要重写它的内容——假设这会更容易 所有这些都应该作为后台进程发生,没有任何保存对话框面板出现。 我知道这是一个老帖子,但是考虑下面的内容,从一个输入文本字段的文本创建一个新的.txt文件。 var file:File = File.desktopDirectory.resolvePat

是否可以使用AS3或AIR创建纯文本文件

示例:我想创建一个名为“MyTextFile.txt”的纯文本文件,使其包含“这是我的文本文件”的文本,并将其保存到我的桌面

另一个选择是让文件已经存在于目录中,因此我只需要重写它的内容——假设这会更容易


所有这些都应该作为后台进程发生,没有任何保存对话框面板出现。

我知道这是一个老帖子,但是考虑下面的内容,从一个输入文本字段的文本创建一个新的.txt文件。

var file:File = File.desktopDirectory.resolvePath("MyTextFile.txt");
var stream:FileStream = new FileStream();
stream.open(file, FileMode.WRITE);
stream.writeUTFBytes("This is my text file.");
stream.close();
var tf:TextField;
var fileRef:FileReference;

function saveFile(evt):void
{
fileRef = new FileReference();
fileRef.save(tf.text, "saveFile.txt");
}

也考虑这篇课文:

在移动设备上运行时,无法看到跟踪语句的输出

函数createTracingTextField(x:Number,y:Number, 宽度:数字,高度:数字):文本字段{

var tracingTF:TextField = new TextField(); 
tracingTF.x = x; 
tracingTF.y = y; 
tracingTF.width = width; 
tracingTF.height = height; 

// A border lets you more easily see the area the text field covers. 
tracingTF.border = true; 
// Left justifying means that the right side of the text field is automatically 
// resized if a line of text is wider than the width of the text field. 
// The bottom is also automatically resized if the number of lines of text 
// exceed the length of the text field. 
tracingTF.autoSize = TextFieldAutoSize.LEFT; 

// Use a text size that works well on the device. 
var myFormat:TextFormat = new TextFormat(); 
myFormat.size = 18; 
tracingTF.defaultTextFormat = myFormat; 

addChild(tracingTF); 
return tracingTF; 
}

等等