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

Numbers As Our Second Variable

Developers use number variables to save and store information (numbers) that they want to access and reuse in the future. Learn how to create different kinds of number variables and see how they can make your life easier as your code gets more complex.

We played around with math and played around with Strings: isn't it time to throw around a few variables that can store numbers? We think so!

We discussed strings as variables earlier. We all know how to declare a string variable and how to assign data to that variable. The method of declaring and assigning a Number variable is the same. The only thing is we use a different keyword here during declaration: 10 guesses what! If you said "Number," you win the booby prize. This will ensure that the variable is of type Integer (Number) and can take data that is in the form of digit(s) that are of type Number.

When it comes to assigning data to the variable, we can assign only what it takes. So data assigned in form of digits is easily understood by the application and it compiles easily when needed. But when we assign data of type string to this variable, the application causes an error (pukes, remember?) at the time of compilation. The application cannot recognize a string for that variable because it was declared to be Number. Therefore, the compiler wants the data contained by the variable to be of type Number. Any data type other than integer (Number) is considered as wrong input from the user and therefore causes an error. While dealing with numbers, another area that needs to be looked into is the correct syntax. We see that the syntax for dealing with variables is the same for both strings and numbers, but it isn't exactly the same. When it comes to a Number, there is a small change: no single or double quotes here while they are compulsory for a String.

Here is an example of declaring a Number variable:

var numNutts: i

Now you have an integer variable all ready to store your numbers! Easy as that.

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