How To

How to Declare Variables in ActionScript

Member
By Mike
User-Submitted Article
(0 Ratings)

ActionScript is the script based language used within Adobe's Flash development software. This scripting language gives developers the ability to make Flash animations more interactive.

As with any programming language a developer needs the ability to declare variables. Here is how that is done.

Difficulty: Easy
Instructions
  1. Step 1

    This tutorial assumes that know how to launch Flash and press F9 to get to the ActionScript development (coding) window. Do that now.

  2. Step 2

    To delcare a variable in ActionScript you start by telling ActionScript you are about to delcare a variable. That is done with the keyword "var".

  3. Step 3

    The nest step is to give your variable name. For our example we will use "myfirstvariable". So the code so far looks like:

    var myfirstvariable

  4. Step 4

    Now you need to give your variable a type, although not required, it is best practice to do so. A variable can be of type, string, boolean, or number to name a few. Here is what our code looks like now:

    var myfirstvariable : Number;

    The colon between the variable name and the type separates the two and the semicolo at the end lets the compiler know that is the end of the line.

    If you wanted to give your variable an initial value you can do this on the same line by typing something similar the following:

    var myfirstvariable : Number = 60;

Post a Comment

Post a Comment
  • Have you done this? Click here to let us know.
I Did This

Related Ads

Computers
Alexia Petrakos,

Meet Alexia Petrakos eHow's Computers Expert.

Get Free Computers Newsletters

Copyright © 1999-2009 eHow, Inc. Use of this web site constitutes acceptance of the eHow Terms of Use and Privacy Policy.   en-US

eHow Computers
eHow_eHow Technology and Electronics