logo
g Text Version
Auto
Beauty & Self
Books & Music
Career
Computers
Education
Family
Food & Wine
Health & Fitness
Hobbies & Crafts
Home & Garden
Money
News & Politics
Relationships
Religion & Spirituality
Society & Culture
Sports
Travel & Leisure
TV & Movies

dailyclick
Bored? Games!
Postcards
Astrology
Take a Quiz
Rate My Photo

new
English Garden
Costuming
Charity
Women's Fashion
Pop Music


dailyclick
All times in EST

Full Schedule
g
g Flash Site
Diane Cipollo
BellaOnline's Flash Editor

g

Flash ActionScript and Data Types

Some programming languages are more strict than others when it comes to following syntax and coding rules. For example, the HTML scripting language is somewhat forgiving when it comes to programming errors. You can have errors in your source code and your web page will still be viewable in the web browser. However, if you have worked with FlashR and ActionScript at all, you know that it is far less forgiving. Therefore, we need to be far more careful when writing our ActionScript code.

One of the coding rules that you will encounter many times when writing your ActionScript code is the use of data types. One place where you will need to use data types is when declaring a new variable. In a previous tutorial, you learned the code to create a new variable.

var name_of_variable = value;
var container = 20;

In the above code from the previous tutorial, we have not declared a data type for our new variable. We need to do that. Let's add the data type to the above code now.

var container:Number = 20;

As you can see, we first add a colon to the end of the name we have given to the variable. We decided to name the variable "container". So the colon is placed at the end and the data type is added to the right of the colon. In the example, the value of the variable is 20 and 20 is a number. Therefore, we need to declare the Number data type.

There are two other data types, which are the String and Boolean.

If we had set the initial value of our container variable to the word "David", then the data type would have been set to String because "David" is a text string of letters. We would also have needed to place quotation marks around the text string. String data is the only type of data that requires you to enclose the data between quotation marks.

The third data type is Boolean. You would use the Boolean data type whenever the value of the variable is true or false. One good example of this is a conditional statement. We could write a conditional statement that tests if a value is greater than 10. If the value is 11, the Boolean will be true. Otherwise, it will be false.





RSS | Related Articles | Previous Features | Site Map


Content copyright © 2008 by Diane Cipollo. All rights reserved.
This content was written by Diane Cipollo. If you wish to use this content in any manner, you need written permission. Contact Diane Cipollo for details.

Digg! g delicious Save to Del.icio.us

g


For FREE email updates, subscribe to the Flash Newsletter


Past Issues


print
Printer Friendly
bookmark
Bookmark
tell friend
Tell a Friend
forum
Forum
email
Email Editor

g features
Flash Procedural Modeling and Inverse Kinematics

Flash Motion Editor and Presets

Flash CS4 Object-based Animation

Archives | Site Map

forum
Forum
email
Contact

Past Issues
memberscenter


vote
Driving Amount
Much more
Slightly more
Slightly less
Much less

g


| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2008 Minerva WebWorks LLC. All rights reserved.


BellaOnline Editor