Dan Thomas wrote:
Can I provide array like access to a custom collection object?
E.g.
Class MyClass
{
private var myArray:Array;
public function getArray():Array
{
return this.myArray;
}
}
[snip]
How can I change it so I can achieve the same thing but with access to
the items like this:
var someClass:MyClass = new MyClass;
thisItem = someClass[0];
Use __resolve:
class MyClass
{
private var myArray:Array;
public function __resolve(name:String):Object
{
if (!isNaN(name)) {
return myArray[Number(name)];
} else {
return false;
}
}
}
But it will not "strict type" properly at all, so you lose major
benefits of using as2 this way. I'd do it:
class MyClass
{
private var myArray:Array;
public function elem(n:Number):Object
{
return myArray[n];
}
}
And:
var someClass:MyClass = new MyClass;
thisItem = someClass.elem(0);
Then you will get proper validation of argument, parameter and return types.
--
Morten Barklund - Information Architect - Shockwaved
Gothersgade 49, 4th floor - DK-1123 Copenhagen K, Denmark
Phone: +45 7027 2227 - Fax: +45 3369 1174
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders