02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous VideoNext Video

Strings As Our First Variable

Developers use variables to save and store information that they want to access and reuse in the future. Learn how to create different kinds of variables and see how they can make your life easier as your code gets more complex. In this video we will work with our first Data Type: the 'String'.

Time to explore the procedure for creating variables and using it in a program. We will first deal with strings before going to numbers. Assigning a string to a variable requires the variable to be declared first along with the data type. We declare a variable like this:

var longAssedStr: String;

Here we can see that the keyword "var" is required to declare any variable. "longAssedStr" is the variable, and the part following the colon shows what type of data this variable is. For strings, would you believe the data type is "String"?? Sure enough it is, so we type the colon followed by "String." The variable declaration must always end with a semi colon as shown.

After declaring a variable, we must assign a string to it if we want to use it later. This can be done in the same line where the variable is declared, in the next line, or elsewhere in the code. We will discuss the first two methods in this section.

Firstly, most developers prefer to declare and assign a variable in a single line: saves space and is more readable. For this we type:

var yoMamaStr: String = "wears army boots";

Here we can see that the semi colon is moved to the end of the line of code, after the string and the variable is set to equal some string within double quotes. Finally, the line must end with a semicolon. In this way the variable is declared and assigned within the same line.

There is another process where we declare the variable in one line and assign data to it in another line. For this we first declare the variable as we said earlier, along with the semicolon. In the next line we type

yoMamaStr = "wears army boots";

The result is same but two lines are used here instead of one. Remember that even the second line must be ended using a semi colon: every line of code you write must end in that semicolon! These little things are very important to remember because they can cause errors during compilation. Nasty errors.

After declaring and assigning a variable using either method, next we see how to use it in the program later. This is very simple and we just need to type the variable in the trace function to print the actual data. It looks like this:

trace(yoMamaStr);

Unlike numbers, a string is the only text data written in double quotes, so it cannot be subjected to any modifications.

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!

Intro

In this video, we will learn the basics concepts of coding in Flash. The main focus is on the output panel. Once we understand Flash's environment, then we learn how to manage the output panel.

03:16

Publish Settings Recap

Get into a rhythm of efficiently setting up your files so you can smoothly transition into writing code. This video shows you how to compile your .swf and .html files..

03:41

Setting Up Our Main Class

Get into a rhythm of efficiently setting up your files so you can smoothly transition into writing code. This video shows you how to set up your script for all the code you'll write from here on out.

04:51

Test Movie

The basics of working with Flash, focusing on the publish settings and testing movies.The basics of working with Flash, focusing on the publish settings and testing movies.

00:58

Trace

For your first programming task, you'll experiment with the 'trace' function and learn how to output data from your application. This can be used to print the desired text at will.

04:08

Single Line Comment

In this video we will learn the syntax of single line comment and the need for its existence in programming, and explore how to create them in actionscript 3 flash.

01:25

Numbers And Basic Math

In order to do great things in flash, all you need is a grasp of basic math. So let's work on computing mathematical equations using the 'trace' function.

06:42

Answer To Math Question

In order to do great things in flash, all you need is a grasp of basic math. So let's work on using the Trace function to compute mathematic equations. We ended the last video with a question, let's s

01:40

Multi line Comments

You already know how to comment line by line but wouldn't it be nicer for you and your fingers if you could cancel out a full block of code? Yes, it is possible using multi line comments.

01:40

What Are Variables?

Learn how to create different kinds of variables and see how they can make your life easier as your code gets more complex. They play a major role in writing the code efficiently.

02:20

Strings As Our First Variable

learn how to create your first string variable in actionscript flash. This video helps you understand how to declare a variable and assign a string to it.

03:42

Error 1067: Implicit Coercion

Help-I just got the dreaded 1067 error... ohh actually it is not that bad it is telling me something... but what? Let’s learn about 1067 error and know how it is helpful to the user

01:21

Numbers As Our Second Variable

Learn how to create different kinds of number variables and see how they can make your life easier as your code gets more complex. Also learn the syntax for declaring all types of numbers

01:56