Re: Help with this "for" loop...!
Hi.
The error I get is below....
ArgumentError: Error #1063: Argument count mismatch on Player(). Expected 3,
got 0. at main/typeCollection()[C:\Documents and Settings\User\My
Documents\Flex Builder 3\main\src\main.mxml:108]
Line 108 is the line var temp:Object = new clazz();
When you ask what is clazz in...clazz represents the second argument of the
typeCollection function and the argument that is passed in is the class Player
which is a class in an external actionscript file.
Actually just got it to work. The problem was....i created the Player class'
constructor function to accept three arguments (id, firstname, surname)....and
so new clazz() should have had 3 arguments....i just changed the code below and
it seems to work..
If there is a better way happy to hear!
Thanks for responding.
private function typeCollection (collection:Object,
claz:Class):ArrayCollection
{
var arr:ArrayCollection = new ArrayCollection();
var a:String;
var b:String;
var c:String;
for each (var item:Object in collection) {
var temp:Object = new claz(a,b,c)
temp = item;
arr.addItem(temp);
}
|