mercredi 25 janvier 2017

AS3/AIR Load/Save Username progress

I am creating an Android application created using Flash AS3. The user will input his/her name, click the previous and next button and press save. After restarting the application, the last frame saved was loaded (with the name). However if I want to input 2nd user with different name and save it in different frame, will the 2nd user's save progress be retained (without deleting the progress of the 1st user?). The problem, when I type the previous user name progress and press load, his saved progress doesn't load. Please help.

I am a newbie in programming. Here is my code so far:

*import flash.events.MouseEvent;


var savedstuff:SharedObject = SharedObject.getLocal("myStuff");

btnSave.addEventListener(MouseEvent.CLICK, SaveData);
btnLoad.addEventListener(MouseEvent.CLICK, LoadData);
btnNext.addEventListener(MouseEvent.CLICK, pageNext);
btnPrev.addEventListener(MouseEvent.CLICK, pagePrev);


function pageNext (e:MouseEvent){
    nextFrame();
}

function pagePrev (e:MouseEvent){
    prevFrame();
}

function SaveData(MouseEvent){
 savedstuff.data.username = nameField.text 
 savedstuff.flush();
 }
function LoadData(MouseEvent){
 if(savedstuff.size>0){ 
 nameField.text = savedstuff.data.username} 
 gotoAndStop(savedstuff.data.saveData);
 }


if(savedstuff.size>0){
nameField.text = savedstuff.data.username}* 

Aucun commentaire:

Enregistrer un commentaire