FUN: Playing around with variables
Now, I’ll show you some cool things you can do with variables. To start up, create a new DYNAMIC text box and give it the variable main. This will be the variable that will bounce around.
STEP 1:
So, let’s start this. read the explanations in the codes, so you’ll understand them! Yeah, by the way, make a new MC and put it off stage! Well, now to the first code part, a whole line, yay!
main=1;//The main variable will be a 1
So, test your movie (CTRL+ENTER) and you’ll see the number one.
STEP 2:
It’s easy to make the variable bounce, and it’s easy to modify the code. But no copy/paste! Put the code on the MC which is off stage.
onClipEvent(enterFrame){//When you enter the frame, the code will run itself over and over again
if(_root.main<10){//If the variable main is less than 10
_root.main+=1;//Variable will go higher
}else{//If it's more than that
_root.main=1;//Main will be reset.
}
}
So, if you want it to count to 100 before it will restart, change “10″ to “100″ and so on. If you want it to start from something else, change the ones to where you want it to start from. You can also put it to count backwards, I’m sure you’ll figure out how
So, now you do probably know variables a bit better, and that’s good, because variables is very important when you go more advanced! It’s almost all about variables and math, lol…. It might sound complicated but it isn’t, it’s kinda fun too
Tags: as2, Basic, flash, fun, variables
You can comment below, or link to this permanent URL from your own site.