flash language_api_subtleties

Other subtleties

Beware, the void type in ActionScript 2 used in signature functions takes a lower-case v in ActionScript 3.

An ActionScript 2 doesn’t send back any value written in the following way:

function initilisation ( ):Void
{
}
In ActionScript 3, the **void** type won’t accept capitals anymore:
function initilisation ( ):void
{
}

ActionScript 3 integrates a new type of data allowing it to indicate that a variable can take any type of data.

In ActionScript 2 we can’t define the type, in ActionScript 3 we use the * type:

var condition:* = true;
var total:* = 5;
var colour:* = 0x990000;
var result:* = 45.4;
var person:* = new Object();
var name:* = "Bobby";

We systematically use the * type in a for each loop because the p variable should be able to take in any type of data:

var person:Object = { name : "Bobby", age : 50 };
for each ( var p:* in person )
{
/* display :
50
Bobby
*/
trace( p );
}

When using a specific type for the p variable we risk implicitly converting the iterated data. In the following code, we use the Boolean type for the variable p:

var person:Object = { name : "Bobby", age : 50 };
for each ( var p:Boolean in person )
{
/* display :
true
true
*/
trace( p );
}

The property content is automatically converted into a Boolean. In the case that data couldn’t be converted into a Boolean the preceding code could raise an execution error.

Now to the present version and new things in the Flash player programming interface. The two main things of Flash 9 player concern the display management as well as the event model.

The next chapter on The event model will talk about the new model in different application exercises. We will learn to master this and discover how to make a profit out of it. We then get into the new display management called Display list and will see how it offers suppleness in terms of manipulation of graphic objects and display optimization. Are you ready for the ActionScript 3 adventure?








Adobe Training center


Mediabox Training Centre © 2000 - 2008 All rights reserved.
Adobe Authorized Training Centre. State convention under number 25 14 02167 14.
Mediabox : SARL au capital de 62.000€ - Activity number: 25 14 02167 14 - SIRET : 493 716 468 00027
MEDIABOX, 102 Avenue des Champs Elysées, 75008 PARIS - Tel. +33(0)2.31.91.96.89 - Fax. +33(0)2.72.68.56.42