AS: Variables
- Toast
-
Toast
- Member since: Apr. 2, 2005
- Offline.
-
- Forum Stats
- Member
- Level 09
- Blank Slate
I have seen many people not knowing what variables are.
I think variables are very important to learn because they can be a great use.I will exaplin why you need to learn variables,how they work,and where/when you can use them.
What are variables?
The variable system has been added to flash since flash no.5.They are
usally used to ismplify scripts or to shorten codes.They are very often used with a boolean,true or false.Basicly,they can be anything you want.I sometimes type su=10; instead of speed_up=10;
How can variables be used?
They are mostly used with "onClipEvent(load){"The only difference between onClipEvent(load){ and onClipEvent(enterFrame){ is that onClipEvent(enterFrame){ performs an action every frame,meaning that if the frame rate is one,the action would be performed every frame.
They can be whatever you want as long as each variable has always got the same name.
Example:
onClipEvent(load)
{
teh_lolz = 5;
}
onClipEvent(enterFrame)
{
this._y -= teh_lolz;
}
That is a very simple code which make "this" go up by 5 pixels every frame.
Every time that "flash sees" teh_lolz.it takes it as a five.It is not hard to understand,is it?
"Why do I need to use variables?"
Sometimes,as the example I gave,you don't have to use variables.But sometimes you have to use ' em.
Example:
I want to make a RPG game,I know how to make a character move,but I want to know how to make him stop when there is a buiding.One of the choices would be to apply the same movement code but to the other direction.
Example:
onClipEvent(enterFrame)
{
this._x +=5;
if(this.hitTest(_root.rightwall))
{
this._x -=5;
}
}
But what if the speed changes during the game?In this case you have to use variables.Instead of reversin the speed,you can simply stop it with variables.
Example:
onClipEvent(load)
{
TehSpeed = 5;
}
onClipEvent(enterFrame)
{
this._x += TehSpeed;
if(this.hitTest(_root.rightwall))
{
TehSpeed=0;
}
else
{
TehSpeed=5;
}
}
I think you got the idea.The tutorial ends here. :o
- Inglor
-
Inglor
- Member since: Jan. 26, 2003
- Offline.
-
- Send Private Message
- Browse All Posts (10,869)
- Block
-
- Forum Stats
- Member
- Level 17
- Blank Slate
SHAME ON YOU!!!!
at least TEACH the correct syntax if you're not going to use it ;)
from AS: Debugging Syntax
Full decleration:
Whenever you make full decleration (which is importent for the compiler to identify your errors) you also specify the return type, for example
var i:Number;
declares a number variable called i
var arr:Array=new Array();
declares a new array.
var s:String="lololololol";
creates a new string variable, names it s, and puts 'lolololol' in it
- Toast
-
Toast
- Member since: Apr. 2, 2005
- Offline.
-
- Forum Stats
- Member
- Level 09
- Blank Slate
At 6/30/05 07:45 AM, Inglor wrote: Shame on Inglor's mum!!!
I sometimes use it but it is not always necessary.
var lol = 5;
Are you teh happy now? >: (
- Inglor
-
Inglor
- Member since: Jan. 26, 2003
- Offline.
-
- Send Private Message
- Browse All Posts (10,869)
- Block
-
- Forum Stats
- Member
- Level 17
- Blank Slate
At 7/23/05 09:26 AM, -Toast- wrote: My Grandma likes it when I put it big and hard up her ass
actually, it's
var lol:Number=5;
- Toast
-
Toast
- Member since: Apr. 2, 2005
- Offline.
-
- Forum Stats
- Member
- Level 09
- Blank Slate
Inglor once typed:
I'm teh 1337!!11!!11
No need for that,this is a basic variables tutorials. lol = 5; and var lol = 5; both work perefectly.
- Inglor
-
Inglor
- Member since: Jan. 26, 2003
- Offline.
-
- Send Private Message
- Browse All Posts (10,869)
- Block
-
- Forum Stats
- Member
- Level 17
- Blank Slate
At 7/23/05 09:30 AM, -Toast- wrote: I touch myself when I look at Denvish's or liam's posts
No need for that,this is a basic variables tutorials. lol = 5; and var lol = 5; both work perefectly.
well, I did state it's advantage for debugging, and for correct syntax, AS 3 does NOT let you just do "lol=5" and enjoy fast speed accell
- liam
-
liam
- Member since: Dec. 11, 2004
- Offline.
-
- Send Private Message
- Browse All Posts (14,243)
- Block
-
- Forum Stats
- Member
- Level 22
- Blank Slate
At 7/23/05 09:30 AM, -Toast- wrote: I touch myself when I look at Denvish's or liam's posts
Well, erm.. thanks :)
Sup, bitches :)
- Denvish
-
Denvish
- Member since: Apr. 25, 2003
- Offline.
-
- Send Private Message
- Browse All Posts (15,977)
- Block
-
- Forum Stats
- Member
- Level 46
- Blank Slate
At 7/23/05 10:02 AM, -liam- wrote: Donkeys arouse me
I hope you use protection
- Inglor
-
Inglor
- Member since: Jan. 26, 2003
- Offline.
-
- Send Private Message
- Browse All Posts (10,869)
- Block
-
- Forum Stats
- Member
- Level 17
- Blank Slate
At 7/23/05 10:28 AM, Denvish wrote:At 7/23/05 10:02 AM, -liam- wrote: Donkeys arouse meI hope you use protection
fuck that made me lol hard, so hard it woke my mom up and now she is mad at me...
- D-to-da-P
-
D-to-da-P
- Member since: Dec. 23, 2004
- Offline.
-
- Forum Stats
- Member
- Level 08
- Blank Slate
At 7/23/05 10:30 AM, D_to_da_P wrote: This thread is awsome haha!
WTF!... haha.
well now i understand this this so called "varey abel" shit. lol
- Inglor
-
Inglor
- Member since: Jan. 26, 2003
- Offline.
-
- Send Private Message
- Browse All Posts (10,869)
- Block
-
- Forum Stats
- Member
- Level 17
- Blank Slate
At 7/23/05 10:43 AM, D_to_da_P wrote: I am gay and I like old beefy truck drivers... and if you're not ok with that, it's your problam >:(
Ok Ok. noone is here to judge you... no need to get all emo
I have your brains (does not link to kevan or another zombie site)
anyhow let's get back to the topic, you didn't address access control at all... oh well
- Mogly
-
Mogly
- Member since: Sep. 5, 2004
- Offline.
-
- Send Private Message
- Browse All Posts (10,151)
- Block
-
- Forum Stats
- Member
- Level 25
- Animator
THE battle of the elite coders has begun! (well, if u minus myself and d to da ps posts that is)
- liam
-
liam
- Member since: Dec. 11, 2004
- Offline.
-
- Send Private Message
- Browse All Posts (14,243)
- Block
-
- Forum Stats
- Member
- Level 22
- Blank Slate
At 7/23/05 10:51 AM, Inglor wrote: I have your brains (does not link to kevan or another zombie site)
No wonder yours is so high O_o
You bloody.. crackpot.
Sup, bitches :)
- D-to-da-P
-
D-to-da-P
- Member since: Dec. 23, 2004
- Offline.
-
- Forum Stats
- Member
- Level 08
- Blank Slate
At 7/23/05 10:51 AM, Inglor wrote: Testicles..... is fur lunch.
just a quick question to u guys with the AS awsomeness.
do you guys memorize all the codes by now or do you have to still find them in the list and select them time to time.
to me i find it amazing to know all the code stuff, im still a n00b at AS.
- Inglor
-
Inglor
- Member since: Jan. 26, 2003
- Offline.
-
- Send Private Message
- Browse All Posts (10,869)
- Block
-
- Forum Stats
- Member
- Level 17
- Blank Slate
At 7/23/05 11:00 AM, D_to_da_P wrote:
do you guys memorize all the codes by now or do you have to still find them in the list and select them time to time.
we don't memorize the codes, we remmember the commands themselves and rethink the codes...
- D-to-da-P
-
D-to-da-P
- Member since: Dec. 23, 2004
- Offline.
-
- Forum Stats
- Member
- Level 08
- Blank Slate
At 7/23/05 11:02 AM, Inglor wrote:
we don't memorize da codes, we remmemba da commands themselves and rethink da codes...
Neat!
- Rustygames
-
Rustygames
- Member since: May. 7, 2005
- Offline.
-
- Forum Stats
- Member
- Level 19
- Programmer
At 6/30/05 05:21 AM, -Toast- wrote: performs an action every frame,meaning that if the frame rate is one,the action would be performed every frame.
WTF?
You mean it will be run once every second if the frame rate is 1 fps. Because it will alwyas run every frame hence the on ENTERFRAME silly boy
- Matt, Rustyarcade.com
- Inglor
-
Inglor
- Member since: Jan. 26, 2003
- Offline.
-
- Send Private Message
- Browse All Posts (10,869)
- Block
-
- Forum Stats
- Member
- Level 17
- Blank Slate
this gets redone, sorry toast, but I'm redoing it... it just doesn't really explain variables...
- Rustygames
-
Rustygames
- Member since: May. 7, 2005
- Offline.
-
- Forum Stats
- Member
- Level 19
- Programmer
At 7/28/05 08:44 AM, Inglor wrote: this gets redone, sorry toast, but I'm redoing it... it just doesn't really explain variables...
Come on lets not be too harsh I mean it does have some good qualities like...
ummm
It explains...
umm...
Well no it doesnt but at leats it links back to AS:MAIN...
Wait..
no.
no it doesnt
- Matt, Rustyarcade.com
- Toast
-
Toast
- Member since: Apr. 2, 2005
- Offline.
-
- Forum Stats
- Member
- Level 09
- Blank Slate
At 7/28/05 08:44 AM, Inglor wrote: this gets redone, sorry toast, but I'm redoing it... it just doesn't really explain variables...
It doesn't mean that you have to ruin this thread : (
- Rantzien
-
Rantzien
- Member since: Jan. 27, 2005
- Offline.
-
- Forum Stats
- Member
- Level 15
- Blank Slate
At 7/28/05 08:47 AM, Ninja-Chicken wrote: Come on lets not be too harsh I mean it does have some good qualities like...
ummm
It explains...
umm...
Well no it doesnt but at leats it links back to AS:MAIN...
Wait..
no.
no it doesnt
Lol. Touché.
- liam
-
liam
- Member since: Dec. 11, 2004
- Offline.
-
- Send Private Message
- Browse All Posts (14,243)
- Block
-
- Forum Stats
- Member
- Level 22
- Blank Slate
The thread shows how to use basic variables, but thats kinda it.. Inglor you wanna do it because you're an AS topic-whore ;p
Sup, bitches :)
- Inglor
-
Inglor
- Member since: Jan. 26, 2003
- Offline.
-
- Send Private Message
- Browse All Posts (10,869)
- Block
-
- Forum Stats
- Member
- Level 17
- Blank Slate
no this thread simply does not cover:
Attributes/Properties
Constants
Variable Types
What Variables are For
Advantages of certein types over the others
Global Variables, Local Variables, how to access a variable in a movieclip from outside of it (this/_parent/super)
And many more...
- Toast
-
Toast
- Member since: Apr. 2, 2005
- Offline.
-
- Forum Stats
- Member
- Level 09
- Blank Slate
At 7/28/05 09:12 AM, Inglor wrote: no this thread simply does not cover:
blah blah blah
And many more...
It's a BASIC bariable tutorial.
It covers what you need to know for a simple platformer or whatever.
It covers:
Introduction.
blah blah bvlah
What they are.
What are variables?
blah blah blah
How to use them.
How can variables be used?
blah blah blah
Example:
code
blah blah blah
and what you need them for.
"Why do I need to use variables?"
blah blah blah
Example:
code
blah blah blah
blah blah blah...
I think it's enough for a basic tutorial...
- liam
-
liam
- Member since: Dec. 11, 2004
- Offline.
-
- Send Private Message
- Browse All Posts (14,243)
- Block
-
- Forum Stats
- Member
- Level 22
- Blank Slate
At 7/28/05 09:12 AM, Inglor wrote: stuff
I agree, we do need a better variable tutorial. I want to know how to use super too, I've never used that.
You're probably the best for the job too :P
Sup, bitches :)
- Inglor
-
Inglor
- Member since: Jan. 26, 2003
- Offline.
-
- Send Private Message
- Browse All Posts (10,869)
- Block
-
- Forum Stats
- Member
- Level 17
- Blank Slate
At 7/28/05 09:19 AM, -Toast- wrote: It covers what you need to know for a simple platformer or whatever.
no it does not, you didn't once say variables are used to store data :P you said some mumbo jumbo about their usage... just because it's simple doesn't mean it has to be bad.
- Toast
-
Toast
- Member since: Apr. 2, 2005
- Offline.
-
- Forum Stats
- Member
- Level 09
- Blank Slate
At 7/28/05 09:23 AM, Inglor wrote: mambo jambo?
I agree,of course, I don't have any problem if you make a new AS: Variables.
Just call it "AS: Inglor's Variables" please :P
Of course a platformer can be done with a simple knowledge of variables. I once made a platformer with my Variables knowledge : / ...
- Inglor
-
Inglor
- Member since: Jan. 26, 2003
- Offline.
-
- Send Private Message
- Browse All Posts (10,869)
- Block
-
- Forum Stats
- Member
- Level 17
- Blank Slate
At 7/28/05 09:25 AM, -Toast- wrote: I like to stick fingers up my ass! it's fun, my whole family does it
No thanks.
Of course a platformer can be done with a simple knowledge of variables. I once made a platformer with my Variables knowledge : / ...
Is it as good as your battle engine? let me guess... it's in pakistan? on a carpet?
Dude, you didn't explain anything in this tutorial no offense but after reading it twice I'm kinda confused about them myself :P
- Toast
-
Toast
- Member since: Apr. 2, 2005
- Offline.
-
- Forum Stats
- Member
- Level 09
- Blank Slate
O
You should be ashamed of talking about my family like that!
BLOCKED!
- Inglor
-
Inglor
- Member since: Jan. 26, 2003
- Offline.
-
- Send Private Message
- Browse All Posts (10,869)
- Block
-
- Forum Stats
- Member
- Level 17
- Blank Slate
At 7/28/05 09:31 AM, -Toast- wrote:OI told you not to tell anyone you son of a bitch! it's a family secret!
It's not my fault... I'll just go ride my magic Alladin carpet in pakistan now >:(
You should be ashamed of talking about my family like that!
BLOCKED!
No need to get all emo again :P you're acting like I care :P


