Wednesday, October 23, 2019
Sunday, October 20, 2019
Friday, September 20, 2019
Tuesday, July 9, 2019
How to save date using AS3.0 in Flash or Adobe Animate CC
///-----FBDimport flash.net.SharedObject;
import flash.events.MouseEvent;
import flash.events.Event;
stop();
///----Change labels of buttons increaseBtn.label = "Increase";
decreaseBtn.label = "Decrease";
clearBtn.label = "Clear";
exitBtn.label = "Exit";
////----Variable of shared object decliration
var so:SharedObject = SharedObject.getLocal("Save");
so.flush();
///----Variable of score decliration
var score:int = 0; ///-----Variable to clear of "so.date.highScore"
var clearScore:Boolean = false;
////----Click event listener
addEventListener(MouseEvent.CLICK, clickHandler); ////-----Function of click event listener
function clickHandler(e:MouseEvent){
///---Switch statement process
switch(e.target){
case increaseBtn:///----In case of "increaseBtn"
score++;
////----Declire if statement to store score as high score
if(score>so.data.highScore){
///----When "score" is grather than "highScore"
so.data.highScore = ""+ score;///----"so.data.highScore" will be "score" }
break;
case decreaseBtn:///----In case of "decreaseBtn"
score--; ////----Declire if statement to store score as high score
if(score>so.data.highScore){///----When "score" is grather than "highScore"
so.data.highScore = ""+ score;///----"so.data.highScore" will be "score" }
break;
case clearBtn:///----In case of "clearBtn"
///---Making "clearScore" boolean variable "true";
clearScore = true;
break;
case exitBtn:
fscommand("quit");///----For close application (NB: It works only on .flv and .exe file, not on .fla) break;
}
}
/////---Enter frame event listener
addEventListener(Event.ENTER_FRAME, update);
function update(e:Event){
///----To show "score" on "outPut_txt" as "text"
outPut_txt.text = ""+ score; ///----To show "so.data.highScore" on "highScore_txt" as "text" highScore_txt.text = so.data.highScore;
if(clearScore){///----When "clearScore" boolean is "true"
so.data.highScore = 0;///----"so.data.highScore" will be "0"
highScore_txt.text = ""+0;///----"highScore_txt" will be "0"
}
}
Sunday, April 14, 2019
Wednesday, October 24, 2018
Sunday, September 9, 2018
Subscribe to:
Posts (Atom)