Home
Username:
Password:
Adobe Flash ActionScript 3.0 for Designers Tutorials

ActionScript Fundamentals pt. 1 / Expressions & Data Types

Subtitles of the Movie

We now come to the term Expressions. In ActionScript basic statements are referred to as Expressions. You may have noticed that many of our lines of script ended in semicolons. Just as in every sentence in English must end in a period, every Expression in ActionScript ends with a semicolon, so here we have an expression: variable myname string equals student. Here's another expression: myname equals james trace myname. We've seen a lot of these expressions in our work so far. Here's a new object based on the sound Class; here's a property that I'm changing, the MovieClip Alpha property. In our first script many of the lines of code were expressions. Here's one expression here: home btn addEventListener, MouseEvent.CLICK handleClick and we had other expressions up here at the top. There's a complete expression right there: gotoAndStop page1. Now Expressions must be complete. This is an example of an incomplete expression: x semicolon - I have the semicolon there but the reason this expression is not complete is that we've not correctly constructed this variable, nor did we initialize it, nor assign it a value, instead we would write this: x colon Number and put the term variable, var, in front of it and then end it with a semicolon, or var x colon Number equals 5. Or here's another expression: myMovieClip1.gotoAndStop open-close parentheses 5 semicolon. Now let's go back and talk more about this concept that I introduced earlier called Data Types. There are many types of data that you can work with in ActionScript. Some of these Data Types are considered Simple Data Types. The String Data Type is one. String is an alphanumeric value like a name or address. Here are several examples of String Data Types. Strings can contain letters, numbers and special characters including spaces. The value of a string is the exact sequence of letters, numbers, or other characters that are strung together that are in between the quotation marks, that's the key. String values always are contained within quotation marks. So here's one, 200 Main St is the value of this variable, myAddress String, myMovie Sting. Notice that here are two variables, myX and myY, both of them string values. Now Strings do not have any value outside the sequence of letters contained within the quotes, so notice that if I have two variables here, myX and myY and they're both strings with the number 5 and number 3 in them, if I add those together I won't get 8, instead I'll get 5 plus 3 or 53. So this underscores that the value of this variable is simply the collection of letters and characters, not the numbers themselves because obviously if I added 5 plus 3, the number, I would get 8 here when I traced it out. There are also numeric Data Types. ActionScript 3.0 has three specific Data Types for numeric data: Number, Integer and Boolean. Numbers include any numeric value including negative values and values with or without a fraction; 4, negative 5, 6.7, three-quarters. Here's an example: variable myFraction colon Number equals 2.56783. Integers are whole numbers, either positive or negative without a fraction: 4, 5, 6, negative 8, negative 9. Here's the application of a variable, myWholeNumber colon int equals negative 3. And the third type is Boolean. You may not be familiar with this one. This is a true or false value, such as whether a movie clip has loaded, or whether two values are equal, so here's a property: myRotation equals true. Now, Simple Data Types represent a single piece of information such as a sequence of text or a single number. Most of the Data Types defined in ActionScript, however, are considered complex Data Types because they entail a set of simple values that have been grouped together. For instance, we could declare a variable with the Date Data Type. This variable represents a single value, a single moment in time, however, the date value is actually made up of many values: the second, minute, hour, date, month, year and so on. Thus, the date variable value is actually defined by several values making the Date Data Type a more complex Data Type than say the String Data Type. Most of the Data Types that have been built into ActionScript are complex Data Types. You might recognize already the following complex types of data. They include Movie Clips, Text Fields and Simple Buttons. You know, as with any other language, in ActionScript 3.0 one must learn the rules of grammar to put statements together. Dot syntax is the convention that ActionScript uses to put objects, properties, methods and more together into statements. You'll notice that I have a lot of dots in my script so far. Here's a. between the p event and the target. Here's another between this object, movie clip, myMovieClip and the property Alpha. So let me now move on to the next movie and go over in more detail writing ActionScript using this. syntax.

Tutorial Information

Course: Adobe Flash ActionScript 3.0 for Designers
Author: James Gonzalez
SKU: 34060
ISBN: 1-935320-82-3
Release Date: 2009-11-09
Duration: 9.5 hrs / 101 lessons
Work Files: Yes
Captions: Available on CD and Online University
Compatibility: Vista/XP/2000, OS X, Linux
QuickTime 7, Flash 8

VTC Sign up & Benefits

  • Unlimited Access
  • 98,729 Video Tutorials (23,265 free)
  • Video Available as Flash or QuickTime
  • Over 1026 Courses
  • $30 for One Month Access
  • Multi-User Discounts Available