Fixed it by Checking if score is higher then 0 and if it is higher the tutorial wont show up.
code:
if (Score > 0) {
Tutorialclouds.visible = false;
}
Frage
Well I have a Movie Clip called TutorialClouds and I want it so when the Tutorial Variable is True it shows up and when its False then it doesn't Show Up. I think the problem is something in my Save system but when it loads it returns that the tutorial variable is false but It still shows up.
Heres my code:
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");
}
Does anyone know how to fix this? Thanks in advance. Sorry if I'm not understandable but I'm Dutch.
Lösung
Fixed it by Checking if score is higher then 0 and if it is higher the tutorial wont show up.
code:
if (Score > 0) {
Tutorialclouds.visible = false;
}