Introduction to AS3: Variable types

The language of actionscript doesn’t use traditional variable types like advanced computer languages (java, C++, c.) Actionscript does things a little different. They like to be a little more generic since creating room in memory is not a heavy issue. Because of this the data types are a fair amount more user friendly.

The variable types flash uses are as follows:

Int” This stands for integer and can be a negative or positive and thus include 0. (-4,-3,-2,-1,0,1,2,3,4,5 are all examples of the int data type.)

Uint” This is very similar to the int data type however it cannot hold negative numbers, or ‘0.’ It can only hold whole numbers.

Number’ A number can be any number. This include negatives, 0, positives, and decimal numbers (floating point) which is the equivalent of declaring a double, float, or single.

String’ This data type will display characters of text. An example of this would be “text,”

Array’ An array data type is more than one item in a variable. This means that could store a list of bowling scores.(1,6,2,4,2).

Boolean’ A Boolean data type traditionally takes up one bit of data because it only stores a 0, or a 1 which is interpreted to true or false.

Custom object’ This can be whatever you want and is declared as a variable type because it is stored in memory much like a variable. The difference is that this can store multiple variable types.

Related posts:

  1. Introduction to AS3: Creating the package.
  2. Introduction to flash AS3
  3. Creating user input with menus in java
  4. Writing and reading objects and arrays to a binary file with java
  5. SQL – An introduction to Keys
Caleb Jonasson

About: Caleb Jonasson

I am a web application developer currently spending my days coding at work, completing contracts and running around with my Nikon. This is my primary place for updates and everything code, technology and database related.
  • Manjiri

    How to read float value from an byte array?
    In my application “End of File error” is occured when I used bytearray.readFloat()
    bytearray.readDouble() methods.
    Can any1 help?

  • http://calebjdesign.com Caleb

    I’m not to sure what you are trying to do without seeing the code. Assuming you are trying to use binary data which is the proper use for the byte array and not an array that is using bytes you will need to make sure that the proper imports have been made.
    import flash.utils.ByteArray;
    import flash.errors.EOFError;

    Also, the End Of File Error that you are receiving is caused when you read a file that is not stored in the array. An example of this is if you were to have a byte array that is filled with a float 14.05 and an int of 5. If you were to read float, read int then read boolean you would have a problem since the data you are trying to get is not stored in the array.

    This should help you out.

    http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/utils/ByteArray.html

  • http://www.tuckersdesigns.blogspot.com Graham

    Thanks for the help Caleb!

    Seriously, I’ve been looking for this list on Adobe.com and inside Flash’s help documents (internally) and I was wondering if there is a “MovieClip” datatype in AS3. Only info I could find on datatypes is for AS2.

    Bookmarked!

  • http://codewithdesign.com Caleb Jonasson

    The movie clip is technically a datatype in AS3 and the datatype is movie clip. It is the small exception which is often thought to be an object but oddly enough is not.