actionscript 3 - FIXED Flash as3 When Tutorial is False it still show Tutorial -
well have movie clip called tutorialclouds , want when tutorial variable true shows , when false doesn't show up. think problem in save system when loads returns tutorial variable false still shows up.
heres code:
import flash.net.sharedobject; stop(); var score = 0; var tutorial = true; var savedataobject:sharedobject; init(); // line goes directly beneath variables function init():void{ // call once set savedataobject = sharedobject.getlocal("test"); // give save data location score = 0; //start 0 score tutorial = true; // start 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 save data trace("no saved data yet."); // if there isn't data on computer... savedataobject.data.savedscore = score; // ...set savedscore 0 savedataobject.data.savedtutorial = tutorial; } else { trace("save data found."); // if did find data... loaddata(); // ...load data } updatescoretext(); // finally, update 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 not display again score += 1; // add 1 score updatescoretext(); // update textfield } function savedata(e:mouseevent):void{ if (tutorial == true) { tutorial = false; } savedataobject.data.savedscore = score; // set saved score current score savedataobject.data.savedtutorial = tutorial; trace("data saved!"); savedataobject.flush(); // save local drive trace(savedataobject.size); // show size of 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 current score saved score tutorial = savedataobject.data.savedtutorial; trace("data loaded!"); } function updatescoretext():void { txtscore.text = ("score: " + score); // set text property of txtscore tutorial = false; trace("score text updated"); trace("tutorial boelean updated"); }
does know how fix this? in advance. sorry if i'm not understandable i'm dutch.
fixed checking if score higher 0 , if higher tutorial wont show up.
code:
if (score > 0) { tutorialclouds.visible = false; }
Comments
Post a Comment