修复了当教程为False时Flash as3仍然显示教程



我有一个名为TutorialClouds的影片剪辑我希望当Tutorial变量为True时它会显示当它为False时它不会显示。我认为问题是在我的保存系统,但当它加载时,它返回教程变量是假的,但它仍然显示。

下面是我的代码:

    import flash.net.SharedObject;
stop();
var Score = 0;
var Tutorial = true;
var saveDataObject:SharedObject;
init(); // this line goes directly beneath the variables
function init():void{ // call once to set everything up
     saveDataObject = SharedObject.getLocal("test"); // give the save data a location
     Score = 0; //start with 0 score
     Tutorial = true; // start with tutorial true
     btnAdd.addEventListener(MouseEvent.CLICK, addScore); // clicking on +1
     btnSave.addEventListener(MouseEvent.CLICK, saveData); // clicking on Save
     btnPopup.addEventListener(MouseEvent.CLICK, RemovePopup); // clicking on Save
     btnExit.addEventListener(MouseEvent.CLICK, Exit); // Exit on click
     if(saveDataObject.data.savedScore == null){ // checks if there is save data
          trace("No saved data yet."); // if there isn't any data on the computer...
          saveDataObject.data.savedScore = Score; // ...set the savedScore to 0
          saveDataObject.data.savedTutorial = Tutorial;
     } else {
          trace("Save data found."); // if we did find data...
          loadData(); // ...load the data
     }
     updateScoreText(); // finally, update the text field
     trace(Tutorial)
}
if (Tutorial == true) {
    TutorialClouds.visible = true;
}
function Exit(e:MouseEvent):void{
    fscommand("quit");
}
function RemovePopup(e:MouseEvent):void{
trace("popup button clicker!");
PopupText.y = 1000;
PopupText.x = 1000;
Popup.y = 1000;
Popup.x = 1000;
btnPopup.y = 1000;
btnPopup.x = 1000;
}
function addScore(e:MouseEvent):void{
    TutorialClouds.visible = false; // Tutorial Will not display again
     Score += 1; // add 1 to the score
     updateScoreText(); // update the textfield
}
function saveData(e:MouseEvent):void{
         if (Tutorial == true) {
         Tutorial = false;
     }
     saveDataObject.data.savedScore = Score; // set the saved score to the current score
     saveDataObject.data.savedTutorial = Tutorial;
     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
     // enable popup
     PopupText.y = 162.4;
     PopupText.x = 1.00;
     Popup.y = 185.75;
     Popup.x = 115.50;
     btnPopup.y = 142.85;
     btnPopup.x = 206.50;
}
function loadData():void{
     Score = saveDataObject.data.savedScore; // set the current score to the saved score
     Tutorial = saveDataObject.data.savedTutorial;
     trace("Data Loaded!");
}
function updateScoreText():void
{
     txtScore.text = ("Score: " + Score); // set the text property of the txtScore
     Tutorial = false;
     trace("Score text updated");
     trace("Tutorial Boelean updated");
}

有人知道如何解决这个问题吗?提前感谢。对不起,如果我听不懂,但我是荷兰人。

通过检查分数是否高于0,如果分数高于0,则教程不会显示

代码:

if (Score > 0) {
Tutorialclouds.visible = false;
}

最新更新