// Creates a fileReference which you will use later to save your text
var fr:FileReference = new FileReference();
// Creates a textField, sets the x,y positions and width, adds it to the stage.
// You can skip this if you have already created a textField on your stage.
var myTextBox:TextField = new TextField();
myTextBox.type = TextFieldType.INPUT;
myTextBox.background = true;
myTextBox.x = 10;
myTextBox.y = 10;
myTextBox.width = 530;
addChild(myTextBox);
myTextBox.text = "Type your text here.";
/* Add code to create a button or draw one on stage */
// Rename "score_btn1" to whatever, I'm just assuming that's what you've called your button
score_btn1.addEventListener(MouseEvent.CLICK, saveFile);
// This is the function that will take text that you type and save it to a .txt file
function saveFile(e:MouseEvent):void {
fr.save(myTextBox.text,"NewFileName.txt");
}
No comments:
Post a Comment