Values in ActionScript

Strings, integers, floats, and booleans are essential data types in programming. Here’s how you can work with them in ActionScript.

package {
    import flash.display.Sprite;
    
    public class Main extends Sprite {
        public function Main() {
            // Strings, which can be added together with "+".
            trace("go" + "lang");
            
            // Integers and floats.
            trace("1+1 =", 1 + 1);
            trace("7.0/3.0 =", 7.0 / 3.0);
            
            // Booleans with boolean operators as you would expect.
            trace(true && false);
            trace(true || false);
            trace(!true);
        }
    }
}

To run the program, compile the code with the ActionScript compiler (mxmlc) and then execute it with a compatible runtime environment.

$ mxmlc Main.as
$ fdb Main.swf
go
golang
1+1 == 2
7.0/3.0 == 2.3333333333333335
false
true
false

Now that we can run and build basic ActionScript programs, let’s learn more about the language.