Groups | Blog | Home
all groups > flash actionscript > may 2004 >

flash actionscript : how to set alias of a data type?


flashin
5/30/2004 7:23:52 PM
I need to have another name for Number type, such as Age, how to set Number's alias so that I can do this:

var age:Age;

instead of:

var age:Number;
mandingo
5/31/2004 3:00:07 AM
Hi,

The usage of
var age:Number;

Is for first line error trapping. The code understands that the variable age
is only allowed to receive a number as a valid parameter. If you tried to
assign "thirty years" into the 'age' variable, then it would have received a
string and would error.
flashin
5/31/2004 3:39:17 AM
mandingo
5/31/2004 4:02:51 AM
That is the point... what is it you want the variable to be? A number? Then
that is what you have...

The specific descriptive part can be your variable name... and with it called
"Age", I think it is fairly self explanatory. I wouldn't expect to find
"Peter" in the Age variable... I would expect a number.

If you are trying to set several ages... then it isn't the need of a new data
type, you need a better way to manage the different variables and object
relationships.

flashin
5/31/2004 6:16:00 PM
I want specific type names which semantically are either Number type equivalent
or subset of Number type, so that I can specify types like this in class:

function oneYearOlder(age:Age[):Age { return age + 1}

instead of:

function oneYearOlder(age:Number):Number {return age + 1;}


AddThis Social Bookmark Button