Be a Supporter!
Toast
Toast
  • Member since: Apr. 2, 2005
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
AS: Variables 2005-06-30 05:21:21 Reply

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


BBS Signature
Inglor
Inglor
  • Member since: Jan. 26, 2003
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to AS: Variables 2005-06-30 07:45:22 Reply

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
Response to AS: Variables 2005-07-23 09:26:41 Reply

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? >: (


BBS Signature
Inglor
Inglor
  • Member since: Jan. 26, 2003
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to AS: Variables 2005-07-23 09:28:36 Reply

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
Response to AS: Variables 2005-07-23 09:30:34 Reply

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.


BBS Signature
Inglor
Inglor
  • Member since: Jan. 26, 2003
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to AS: Variables 2005-07-23 09:32:52 Reply

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.
Forum Stats
Member
Level 22
Blank Slate
Response to AS: Variables 2005-07-23 10:02:52 Reply

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 :)

BBS Signature
Denvish
Denvish
  • Member since: Apr. 25, 2003
  • Offline.
Forum Stats
Member
Level 46
Blank Slate
Response to AS: Variables 2005-07-23 10:28:13 Reply

At 7/23/05 10:02 AM, -liam- wrote: Donkeys arouse me

I hope you use protection


- - Flash - Music - Images - -

BBS Signature
Inglor
Inglor
  • Member since: Jan. 26, 2003
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to AS: Variables 2005-07-23 10:30:30 Reply

At 7/23/05 10:28 AM, Denvish wrote:
At 7/23/05 10:02 AM, -liam- wrote: Donkeys arouse me
I 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
Response to AS: Variables 2005-07-23 10:43:37 Reply

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.
Forum Stats
Member
Level 17
Blank Slate
Response to AS: Variables 2005-07-23 10:51:40 Reply

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.
Forum Stats
Member
Level 25
Animator
Response to AS: Variables 2005-07-23 10:55:40 Reply

THE battle of the elite coders has begun! (well, if u minus myself and d to da ps posts that is)


WEBSITE
BLOG ~ Dont fuck around with my dog. All that I can see I steal. ~
NG FFR ~ Automatic for the people.

BBS Signature
liam
liam
  • Member since: Dec. 11, 2004
  • Offline.
Forum Stats
Member
Level 22
Blank Slate
Response to AS: Variables 2005-07-23 10:55:49 Reply

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 :)

BBS Signature
D-to-da-P
D-to-da-P
  • Member since: Dec. 23, 2004
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to AS: Variables 2005-07-23 11:00:42 Reply

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.
Forum Stats
Member
Level 17
Blank Slate
Response to AS: Variables 2005-07-23 11:02:01 Reply

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
Response to AS: Variables 2005-07-23 11:05:29 Reply

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
Response to AS: Variables 2005-07-28 08:42:47 Reply

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.
Forum Stats
Member
Level 17
Blank Slate
Response to AS: Variables 2005-07-28 08:44:52 Reply

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
Response to AS: Variables 2005-07-28 08:47:29 Reply

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
Response to AS: Variables 2005-07-28 08:56:13 Reply

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 : (


BBS Signature
Rantzien
Rantzien
  • Member since: Jan. 27, 2005
  • Offline.
Forum Stats
Member
Level 15
Blank Slate
Response to AS: Variables 2005-07-28 08:58:41 Reply

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é.


BBS Signature
liam
liam
  • Member since: Dec. 11, 2004
  • Offline.
Forum Stats
Member
Level 22
Blank Slate
Response to AS: Variables 2005-07-28 09:07:30 Reply

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 :)

BBS Signature
Inglor
Inglor
  • Member since: Jan. 26, 2003
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to AS: Variables 2005-07-28 09:12:26 Reply

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
Response to AS: Variables 2005-07-28 09:19:38 Reply

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...


BBS Signature
liam
liam
  • Member since: Dec. 11, 2004
  • Offline.
Forum Stats
Member
Level 22
Blank Slate
Response to AS: Variables 2005-07-28 09:22:27 Reply

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 :)

BBS Signature
Inglor
Inglor
  • Member since: Jan. 26, 2003
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to AS: Variables 2005-07-28 09:23:02 Reply

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
Response to AS: Variables 2005-07-28 09:25:31 Reply

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 : / ...


BBS Signature
Inglor
Inglor
  • Member since: Jan. 26, 2003
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to AS: Variables 2005-07-28 09:29:45 Reply

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
Response to AS: Variables 2005-07-28 09:31:35 Reply

O

You should be ashamed of talking about my family like that!

BLOCKED!


BBS Signature
Inglor
Inglor
  • Member since: Jan. 26, 2003
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to AS: Variables 2005-07-28 09:36:59 Reply

At 7/28/05 09:31 AM, -Toast- wrote:
O
I 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