Jump to content
xisto Community
Sign in to follow this  
Mononoko

How Do I define variables in flash

Recommended Posts

were doing a course in ICT called multimedia, but i dont know how to define variablesand whenever i ask my teacher he always goes "were not that far yet"he doesn't even look at what i have done, assumes I'm not finished, when i am, the only thing i need now is a scoring system

Share this post


Link to post
Share on other sites

What language are you using? i would assume its visual basic, AKA "VB", if so the usual way to do this is with code like this:

Dim VariableName As TypeEG:Dim Score As IntegerAnd then to assign a value:Score = "1"

That probably isnt completely right but it will give you an idea, i, sure the first part, "Dim.." is fine but as for the secnd im not so sure, i dont use VB much. If its anther language let us know and someone can help :D

I remember doing multimedia at college... it was dreadful...

Share this post


Link to post
Share on other sites

were doing a course in ICT called multimedia, but i dont know how to define variablesand whenever i ask my teacher he always goes
"were not that far yet"

he doesn't even look at what i have done, assumes I'm not finished, when i am, the only thing i need now is a scoring system

I'm guessing C++ is the language you are using.
type name;
Where type is the type of variable. Where name is the name of the variable. The type can be int for integers, float for real numbers, char for characters(it will only store one character if it isn't an array or pointer), and a host of various other types that you might not find useful under normal circumstances at this point. This is the basic way to declare variables in any C-like language(Java, C, C++, mainly) but PHP, and Perl which don't require variables to be defined.

To assign a variable a value:
name = value;

Remember to put these in your functions like main() or it will be a global variable. Global variables are frowned upon in C.
Edited by Tetraca (see edit history)

Share this post


Link to post
Share on other sites

In the description of the topic is what language he is talking about: "define variables in flash". So I'm guessing you mean actionscript. Now most programing languages are very similar when defining variables. Flash isn't as strict as c++ is so you do not need to put the type of variable when declaring it. To declare a variable in flash all you need to write is

var variablename;

After the variable is defined, you can then set it the same way you do it as shown above in both c++ and vb (and also pretty much every other language).
variablename=value;

Value can either be another variable, a string (text, which must be surrounded in quotations ex: variablename="text":D, or a number (there are many different value types for holding numbers, when you assign a number to a variable in flash it automatically assigns the variable to the correct type so you do not need to worry about it).

I assume your class will go over this shortly along with all of the different variable types.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.