00:00
00:00
Newgrounds Background Image Theme

DezTenShot67 just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

AS: Variables

7,710 Views | 51 Replies
New Topic Respond to this Topic

AS: Variables 2005-06-30 05:21:21


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

Response to AS: Variables 2005-06-30 07:45:22


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

Response to AS: Variables 2005-07-23 09:26:41


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

Response to AS: Variables 2005-07-23 09:28:36


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;

Response to AS: Variables 2005-07-23 09:30:34


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

Response to AS: Variables 2005-07-23 09:32:52


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

Response to AS: Variables 2005-07-23 10:02:52


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

Response to AS: Variables 2005-07-23 10:28:13


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

I hope you use protection


- - Flash - Music - Images - -

BBS Signature

Response to AS: Variables 2005-07-23 10:30:30


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

Response to AS: Variables 2005-07-23 10:43:37


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

Response to AS: Variables 2005-07-23 10:51:40


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

Response to AS: Variables 2005-07-23 10:55:40


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

Response to AS: Variables 2005-07-23 10:55:49


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

Response to AS: Variables 2005-07-23 11:00:42


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.

Response to AS: Variables 2005-07-23 11:02:01


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

Response to AS: Variables 2005-07-23 11:05:29


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!

Response to AS: Variables 2005-07-28 08:42:47


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

Response to AS: Variables 2005-07-28 08:44:52


this gets redone, sorry toast, but I'm redoing it... it just doesn't really explain variables...

Response to AS: Variables 2005-07-28 08:47:29


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

Response to AS: Variables 2005-07-28 08:56:13


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

Response to AS: Variables 2005-07-28 08:58:41


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

Response to AS: Variables 2005-07-28 09:07:30


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

Response to AS: Variables 2005-07-28 09:12:26


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

Response to AS: Variables 2005-07-28 09:19:38


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

Response to AS: Variables 2005-07-28 09:22:27


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

Response to AS: Variables 2005-07-28 09:23:02


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.

Response to AS: Variables 2005-07-28 09:25:31


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

Response to AS: Variables 2005-07-28 09:29:45


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

Response to AS: Variables 2005-07-28 09:31:35


O

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

BLOCKED!


BBS Signature

Response to AS: Variables 2005-07-28 09:36:59


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