0
嗯,我有一個名爲TutorialClouds的影片剪輯,我希望它,所以當教程變量爲真時,它顯示出來,當它的假,然後它不顯示。我認爲這個問題在我的保存系統中是有的,但是當它加載時,它返回的是tutorial變量是false,但它仍然顯示出來。FIXED Flash as3當教程是假的時候,它仍然顯示教程
繼承人我的代碼:
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");
}
有誰知道如何解決這一問題? 在此先感謝。 對不起,如果我不明白,但我是荷蘭人。