ActionScript 3.0, like many other programming languages, contains a number of basic data types commonly known as primitives. ActionScript 3.0 contains five primitive data types, which is far less than other languages like .NET or Java.
|
Data Type |
Function |
|
String |
A character or series of characters |
|
Boolean |
A value that is either true or false |
|
int |
Positive or negative whole numbers |
|
uint |
Positive whole numbers |
|
Number |
Positive and negative whole and real numbers |
Strings
Strings are a very important data type in programming languages that support them. For instance, string value can represent a sentence, a phrase, a word, a letter, or a directory location in an application, all of which are vital to many applications developed.
In the above example, when the value of String str is traced, the output will read This is a string.
Booleans
Booleans are a great way to evaluate whether a statement in code is true or not. A developer can program an application to do something whether or not a statement is true. For example:
The above code will set the Boolean value to false because the value of five is not greater than 6. After that, the second if statement checks to see whether or not the Boolean’s value is set to true or false. Seeing that the Boolean is false, it will return the trace statement in the else statement.
Integers, Unsigned Integers, and Numbers
Flash comes equipped with a small set of numeric data types that allow the flexibility for almost any developer. If a variable needs to store positive whole numbers, then one would use an unsigned integer to store the values. For whole numbers that are positive and negative, using an integer or Number would be ideal. The difference between integers and Numbers is that Numbers can also store real number values whereas integers only store whole numbers. Also, Number data types can store a headache inducing amount of data compared to integers and unsigned integers. Here’s a breakdown of numeric data type values in Flash
|
Data Type |
Minimum Value |
Maximum Value |
|
integer |
-2,147,483,648 |
2,147,483,647 |
|
unsigned integer |
0 |
4,294,967,295 |
|
Number |
4.9406564584124654e-324 |
1.79769313486231e+308 |
As you can see, Numbers are great for not only storing real numbers, but also for REALLY HUGE values. Remember, when programming, choose the numeric data type that’s the most ideal for the situation. For example, if you plan on storing numeric whole number values (positive or negative) that aren’t going to contain decimals, then you’re probably best off using integers. Any time decimals or real numbers in general are involved, use Numbers. When you are developing any type of application or animation, you have to keep system resources in mind to the best of your ability. By doing so, this ensures optimal performance on most computers.
As always, source code is available here.
When creating Adobe AIR applications, one of the more important (and easily overlooked) things that people like is System Tray Icons (Windows) or Dock Icons (Mac) for simple user commands such as changing preferences in the application or exiting entirely.
One of the many advantages of using Adobe AIR is the cross platform support, but how does an application know if it’s running on a Windows or Mac platform in order to accommodate a System Tray or Dock icon for each respective environment? The development team behind Adobe AIR have conquered this problem for developers. Within the NativeApplication Class there’s two boolean properties to resolve this problem. The boolean property supportsDockIcon is used to detect whether or not the native operating system supports Dock Icons (Mac) while the other, supportsSystemTrayIcon, is used for Windows based systems.
What can be done, is that an if-else if statement can be written to compensate for both environments. In most cases, you’d want the logic in both parts of the statement to be similar, with the exception of the size of the icon. This way, continuity and consistency is maintained between both platforms.
As you can see, the idea is pretty simple. If the boolean returns true, then the respective statement will execute. If you would like this code expanded on, please let me know. I’d be more than happy to either update the post or write a follow up post on this topic.
Happy coding!
Generate code faster in Adobes new Flash Builder 4. Computer Scientist David Zuckerman focuses on how developers can benefit from the improved package explorer feature.
Duane Nickull shows off the new HTTP data wizards in Flash Builder 4. In this video, he builds an application to retrieve remote xml data without having to code.
David Zuckerman, Engineer on the Adobe Flash Builder 4 Team, shows how conditional breakpoints and unit testing work to debug and test code in the new version of Flex.