Ok some of you might be surprised ive been using flash for 3 years already and i still dont know how or what do i use a variable for, ive bought a few books but these dont cover a basic explanation of how and what i can use these for and the benefits of using them, so im asking you my fellow brothers in flash which is the easiest way to learn what variables are and why should i use them
Ive browsed through actionscript.org, here and flashkit but i want something really dumbed down since ive never dealt with a variable before, i just want to basicaly understand what it is and then work my way up on its diffrent functions
animation? nothing. If you are just animating then you really won’t be using variables at all.
Interaction: everything.
Variables control everything. Take a look at some Actionscript and you’ll see how variables are the driving force behind every script. You may not know what the variable is doing there, but it needs to be there. It has a purpose, a job to do.
It really depends on what you need it for. Variables can do a myriad of different things. There is not cut-and-dry answer to your question…
so really, instead of writing out the number 5 every time you need it in a script, its neater and easier to understand if you just put a variable there instead…
That code will move a movie clip to the right 10 points every frame. When programming longer scripts you would want to use variables to rwrite the information because it makes the code cleaner.
This code multiplies speed times friction in every frame and eventually you will see that the movie clip stops moving because speed will eventually equal zero…
You need variables in dynamic text boxes to have things appear in them and then reference them later in scripts.
If you want a counter in your script to count everytime that script is activated, like duplicateMovieClip for instance, you use:
[AS]
i++;
[/AS]
Variables can be strings, like what Jubba said, that you need to put the clock on my footer like:
[AS]
onClipEvent(enterFrame){
now=new Date();
h=now.getHours();
m=now.getMinutes();
s=now.getSeconds();
if(h>12){
h-=12;
}
if(h==0){
h=12;
}
if(m<10){
m=“0”+m;
}
if(s<10){
s=“0”+s;
}
_root.display=h+":"+m+":"+s;
}
[/AS]
And don’t even get me started on getTimer()!! Sorry, just wanted to chime in and say hi…:beam: