casting

Quicktip #4: Casting and the ‘as’-keyword

Posted by Bart Claessens on February 15, 2009
ActionScript 3, Flash, Flex, QuickTips / 3 Comments

Some of you will probably know the ‘as’-keyword. If not, a short explanation:

The ‘as’-keyword is used to cast an object to another one. (Well it’s not exactly ‘casting’, if someone feels like explaining the difference between casting with the ‘as’-keyword or by using the class constructor, please go ahead in the comment below!).

To make it more concrete, here is an example: Continue reading…

  • Share/Bookmark

Tags: , ,

Quicktip #1: Casting to Number()

Posted by Bart Claessens on November 21, 2008
QuickTips / No Comments

Did you know that casting a String to a Number using the ‘as’ operator returns 0 instead of the correct number? Use the Number() constructor to cast it correctly. The same applies for ‘int’ and ‘uint’.

Continue reading…

  • Share/Bookmark

Tags: , , , , ,