Archive for the 'Books' Category

A Free Book To Dive Into Python

Update: Shang (5566) left in the comments that there’s another well written book at A Byte Of Python. Thanks Shang! :)

Dive Into PythonTrying to learn Python but not sure where to start? I think you’ve found the right place. ;)

The title of this post could not be any clearer. :D This free book, “Dive Into Python”, is an excellent resource to get started and you can read it online or download it.

AddThis Social Bookmark Button

Free Book: The Art & Science Of CSS

The Art & Science Of CSSHelping to spread the love from SitePoint.com; they are currently having a twitaway offer, which in a nutshell, lets you download “The Art & Science Of CSS” for free! :D

I knew I want it, so I got mine. Here’s how to get your own. Do hurry though, it’s a *limited 14 days* offer only. ;)

AddThis Social Bookmark Button

Apress $10 eBooks!

Apress eBook Deal of the DayThis is something you want to bookmark and check back on a daily basis. Apress is dishing out one eBook on a daily basis, at the price of just *USD10!*

With a little patience, I’m sure you will be able to get your hands on something useful or fun to whatever that you want to do. ;)

AddThis Social Bookmark Button

Conversion to Primitive Types

When I first determined to datatype my codes strictly, I had this illusion that I must assign everything according to their data types. Here’s an example of me being disillusioned :P :

var age:uint = 2; // hardcoded value for testing
var isBorn:Boolean = ( age == 0 ) ? false : true;
trace( isBorn ); // returns true.
 
age = 0;
isBorn = ( age == 0 ) ? false : true;
trace( isBorn ); // returns false.

As you can see from the above example, it was not pretty. It was only when I read the section of Conversion to Primitive Types in Essential ActionScript 3.0 did it dispels my misconception. :D

So here’s what I can actually do:

var age:uint = 2;
var isBorn:Boolean = age;
trace( isBorn ); // returns true as well.
 
age = 0;
isBorn = age;
trace( isBorn ); // returns false. Works well!

In another typical scenario, if I wanted to make a movieclip’s visibility to false and alpha to 0, instead of doing:

mc.visible = false;
mc.alpha = 0;

I can just:

mc.visible = mc.alpha = 0;

** Do you see the advantage already? ** :)

More info about type conversions can be found here on Adobe LiveDocs.

The information below is referenced from: Essential ActionScript 3.0 by Colin Moock. Copyright 2007 O’Reilly Media, Inc., 0-596-52694-6

Table 1: Conversion to Number

Shows the results of converting various datatypes to the Number type.

Original Data Result after conversion
undefined NaN (the special numeric value "Not a Number", which represents invalid numeric data).
null 0
int The same number
uint The same number
Boolean 1 if the original value is true; 0 if the original value is false
Numeric string Equivalent numeric value if string is composed only of base-10 or base-16 numbers, whitespace, exponent, decimal point, plus sign, or minus sign (e.g., "-1.485e2" becomes -148.5)
Empty string 0
"Infinity" Infinity
"-Inifinity" -Infinity
Other strings NaN
Object NaN

Table 2: Conversion to int

Shows the results of converting various datatypes to the int type.

Original Data Result after conversion
undefined 0
null 0
Number or uint An integer in the range -231 through 231-1, out of range values are brought into range using the algorithm listed in section 9.5 of the Standard ECMA-262, Third Edition
Boolean 1 if the original value is true; 0 if the original value is false
Numeric string Equivalent numeric value, converted to signed-integer format
Empty string 0
"Infinity" 0
"-Inifinity" 0
Other strings 0
Object 0

Table 3: Conversion to uint

Shows the results of converting various datatypes to the uint type.

Original Data Result after conversion
undefined 0
null 0
Number or int An integer in the range 0 through 231-1, out of range values are brought into range using the algorithm listed in section 9.6 of the Standard ECMA-262, Third Edition
Boolean 1 if the original value is true; 0 if the original value is false
Numeric string Equivalent numeric value, converted to unsigned-integer format
Empty string 0
"Infinity" 0
"-Inifinity" 0
Other strings 0
Object 0

Table 4: Conversion to String

Shows the results of converting various datatypes to the String type.

Original Data Result after conversion
undefined "undefined"
null "null"
Boolean "true" if the original value was true; "false" if the original value was false
NaN "NaN"
0 "0"
Infinity "Infinity"
-Infinity "-Infinity"
Other numeric value String equivalent of the number. For example, 944.345 becomes "944.45".
Object The value that results from calling toString() on the object. By default, the toString() method of an object returns "[object className]", where className is the object's class. The toString() method can be overridden to return a more useful result. For example, toString() of a Date object returns the time in human-readable format, such as: "Sun May 14 11:38:10 EDT 2000"), while toString() of an Array object returns comma-separated list of element values.

Table 5: Conversion to Boolean

Shows the results of converting various datatypes to the Boolean type.

Original Data Result after conversion
undefined false
null false
NaN false
0 false
Infinity true
-Infinity true
Other numeric value true
Nonempty string true
Empty string ("") false
Object true

AddThis Social Bookmark Button

Learning ActionScript 3.0

IMO, ActionScript 3.0 seems like another language altogether, as the similarities with ActionScript 1/2 are not that much at all. Developers may have a tough time to learn (I had my own mental block a while ago), and to designers, it seems nearly impossible to start grasping this new powerful, yet daunting to learn language. :(

The community has been great though. With reference to Guy Watson aka FlashGuru’s post on ActionScript 3 Resources, Trevor McCauley aka Senocular has written a couple of very useful materials to start learning AS3. They’re definitely a great help over the last few days of AS3 development as I’ve referred to them CONSTANTLY. :D

I definitely recommend getting Colin Moock’s book on Essential ActionScript 3.0!

Edit: Check out this google search!

AddThis Social Bookmark Button