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

Addition

<p>Let's study the addition of both <a href="/courses/video/4/154/Strings-As-Our-First-Variable.html">strings</a> and <a href="/courses/video/4/156/Numbers-As-Our-Second-Variable.html">numbers</a>. Numbers we can guess, but what happens when you add two strings? If you think that isn't enough, we'll even look at <a href="/courses/video/4/155/Error-1067-Implicit-Coercion.html">error</a> 1084 and figure out how to avoid it.</p> <p>We know how to add two <a href="/courses/video/5/161/Numbers-int-And-unit.html">integers</a> using Flash: it's very easy and can be done using the '+' <a href="/course/basics/operators">operators</a>. To <a href="/courses/video/4/31/Trace.html">trace</a> the addition of two numbers, there isn't much effort involved. But as we develop as programmers, we may have to add something more than just numbers. We need to perform additions on not only integers but Strings as well. You might wonder how and why we add strings. It's the same as adding numbers, but the strings to be summed up must be within double quotes as usual. Once you put a + sign between the two strings, the output is one string containing both the words/sentences together. The addition of strings (<b>concatenation</b>) is also performed using the '+' operator.</p> <h2>Why do we need to add strings?</h2> <p>Many people might think that if the need is just to combine the words together, why can't we directly write two words together within the double quotes? This will be answered when we start dealing with some bigger programs where the two strings are needed separately but must also be combined later, so addition becomes a must. An easy example: one string that must be combined with only one of twelve: &quot;My birthday is &quot; and one of &quot;Dec&quot;, &quot;Jan&quot;, &quot;Feb&quot;... You now know how to use <a href="/courses/video/4/154/Strings-As-Our-First-Variable.html">strings in variables</a>. Your code could look like this:</p> <p><i>trace(&quot;My birthday is&quot;+ monthStr);</i></p> <p>Variables add extra control in our creation process. We declare variables and assign them strings separately because these strings are needed in the program separately. Hence, we use the first variable wherever the first string is needed and second variable where the second string is needed etc. So now if we want a string which is the combination of these two, we don't waste time in declaring a new variable and assigning it the combined string. In fact, we add these two variables together to form the combined string as output.</p> <p>The point that must be remembered is that addition is not just about adding numbers but strings as well. The good news is even through this is a new concept, its the exact same process we did for <a href="/courses/video/5/157/Using-Variables.html">variables</a> – only the outcome is two strings combined. An example taken from an ancient internet joke:</p> <p><i>var strPet:String=&quot;Benoline&quot;; // user enters the name of their first pet into String strPet</i></p> <p><i>var strStreet:String=&quot;Programmer Blvd&quot;; // user enters the name of the first street they lived on into String strStreet</i></p> <p><i>trace("Your stripper name is " + strPet + strStreet);</i></p>

Intro

In our mission to learn how to become a developer, things are getting more complicated. We will learn about the importance of variables, brackets, operators and even talk more deeply about data types

01:52

What Opens Must Close

Quick detour - I want to let you in on a little secret. It's my favorite shortcut in the book and will help you manage the many brackets with which you work.

06:33

Addition

Let's study string addition! We will see how we add strings together and how we add numbers together. And if you think that isn't enough, we'll even look at error 1084 and figure out how to avoid it.

03:33

Mixing Strings and Numbers

When working with numbers and strings it's important to prevent Compiler (Flash) from automatically converting data so you'll not be automatically confused.

02:04

Converting Strings to Numbers

How do we take that string and let Flash know we actually want it to be a number? The answer is simple: learn a new function. This function type is called Casting.

01:16

Using Variables

So, we have variables and we know how to create them but how can we actually use them and for what? We agree, it's time to see them in action through this video.

06:15

What are Primitives?

It’s important to differentiate between primitive and complex data types in Flash. Have no clue what primitive values are, well jump in and let's figure it out!

02:09

Deeper Look: Defining Variables

Now that we know what variables are it's time to look deeper into their structure and how to play with them. Also, we'll learn about a new error type we can now check to avoid - Error 1120.

04:10

Deeper Look: Math Operators

Things are starting to fall into the right place! Lets revisit the math operators and add a few new tricks and shortcuts. Also learn about a new operator (%) used to find the modulus of two numbers.

05:36

Numbers, int And unit

Though all three types Number, int and uint are used to represent numbers, there are few minor differences between them which help us save time. Lets learn what are they and when should we use them

07:19

Boolean

Boolean are simple. They are really only place holders that can hold only two possible values: true or false (0 or 1, yes or no...) Lets learn how Boolean variables are used in programming.

01:48