String, Boolean, Number, int, uint are all Objects...
var a:String = "";
trace(a is Object); //true
var b:uint;
trace(b is Object); //true
I find * useful when I don't want to explicitly type cast:
function a():Object {
return "hi";
}
var b:String = a(); //compile time error
function a():*
We've been developing a flash game over the last few weeks, and we're
finding more and more that the flash player on PC and Mac run terrifyingly
differently. In my previous experience, website I've built have run far
better on my Mac than on other PCs, but this time its the opposite. The PC
version
Also, mind this:
var a:*;
trace(a);
// undefined
var b:Object;
trace(b);
// null
An Object can't be undefined.
Cheers,
Claus.
Ian Thomas wrote:
'*' means "discard type checking"
'Object' means 'treat it as type Object'
If you have functions:
public function getThing():*
{
return new Buc
'*' means "discard type checking"
'Object' means 'treat it as type Object'
If you have functions:
public function getThing():*
{
return new Bucket();
}
public function getAnotherThing():Object
{
return new Bucket();
}
then this will compile:
var someVar:Bucket=getThing(); // Ignores type
4 matches
Mail list logo