Skip to Content
ActionScript: The Definitive Guide
book

ActionScript: The Definitive Guide

by Colin Moock
May 2001
Intermediate to advanced
720 pages
23h 24m
English
O'Reilly Media, Inc.
Content preview from ActionScript: The Definitive Guide

Assigning Variables

Now comes the fun part—putting some data into our variables. If you’re still playing along with the bank analogy, this is the “deposit money into our account” step. To assign a variable a value, we use:

               variableName = value;

where variableName is the name of a variable, and value is the data we’re assigning to that variable. Here’s an applied example:

bookTitle = "ActionScript: The Definitive Guide";

On the left side of the equal sign, the word bookTitle is the variable’s name (its identifier). On the right side of the equal sign, the phrase “ActionScript: The Definitive Guide” is the variable’s value —the datum you’re depositing. The equal sign itself is called the assignment operator. It tells Flash that you want to assign (i.e., deposit) whatever is on the right of the equal sign to the variable shown on the left. If the variable on the left doesn’t exist yet, Flash creates it (though relying on the interpreter to implicitly create variables isn’t recommended).

Here are two more variable assignment examples:

speed = 25;
output = "thank you";

The first example assigns the integer 25 to the variable speed, showing that variables can contain numbers as well as text. We’ll see shortly that they can contain other kinds of data as well. The second example assigns the text “thank you” to the variable output. Notice that we use straight double quotation marks (” “) to delimit a text string in ActionScript.

Now let’s look at a slightly more complicated example that assigns ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Actionscript Cookbook

Actionscript Cookbook

Joey Lott
ActionScript 3.0 Design Patterns

ActionScript 3.0 Design Patterns

William Sanders, Chandima Cumaranatunge

Publisher Resources

ISBN: 1565928520Catalog PageErrata