Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var playerName; {
- function PlayerNameInput(): void { // call once to set everything up
- saveDataObject = SharedObject.getLocal("DataBattle/character/name"); // give the save data a location
- saveDataObject.data.characterName = playerName;
- function addName(e: TouchEvent): void {
- var myTextBox1: TextField;
- var txtPlayer: TextField;
- function captureText() {
- myTextBox1.type = TextFieldType.INPUT;
- addChild(myTextBox1);
- addChild(txtPlayer);
- myTextBox1.addEventListener(TextEvent.TEXT_INPUT, textInputCapture);
- }
- function textInputCapture(event: TextEvent): void {
- txtPlayer.text = event.text;
- }
- if (playerName == null) { // checks if there is save data
- trace("No Player data yet."); // if there isn't any data on the computer...
- } else {
- trace("Player data found."); // if we did find data...
- loadData1(); // ...load the data
- }
- function loadData1(): void {
- playerName = txtPlayer;
- trace("Data Loaded!");
- }
- }
- }
- }
- function saveData(): void {
- saveDataObject.data.characterName = playerName; // set the saved score to the current score
- trace("Data Saved!");
- saveDataObject.flush(); // immediately save to the local drive
- trace(saveDataObject.size); // this will show the size of the save file, in bytes
- }
Advertisement
Add Comment
Please, Sign In to add comment