AS3またはAIRでプレーンテキストファイルを作成することは可能ですか?
例:「MyTextFile.txt」という名前のプレーンテキストファイルを作成し、「これは私のテキストファイルです」というテキストを含めるようにします。デスクトップに保存します。
別のオプションは、ファイルをディレクトリにすでに存在させることです。そのため、内容を書き直すだけで済みます。
これらはすべて、保存ダイアログパネルが表示されることなく、バックグラウンドプロセスとして実行される必要があります。
AS3またはAIRでプレーンテキストファイルを作成することは可能ですか?
例:「MyTextFile.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();
これが古い投稿であることは知っていますが、入力テキストフィールドのテキストから新しい.txtファイルを作成するには、次のことを考慮してください。
var tf:TextField;
var fileRef:FileReference;
function saveFile(evt):void
{
fileRef = new FileReference();
fileRef.save(tf.text, "saveFile.txt");
}
次のテキストも考慮してください。
モバイル デバイスで実行している場合、トレース ステートメントからの出力は表示されません。
function createTracingTextField(x:Number, y:Number, width:Number, height:Number):TextField {
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;
}
などなど…