我有一个名为TutorialClouds的影片剪辑,我想要它,所以当教程变量为True时它会显示,当它显示为False时它就不会显示。我认为问题出现在我的Save系统中,但是当它加载时它会返回教程变量为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)
通过检查得分是否高于0来修复它,如果它更高,则教程不会显示。
代码:
if (Score > 0) {
Tutorialclouds.visible = false;
}