There's no way to make a function parameter more "narrow" in an override, or 
have multiple signatures for functions, so there's no way to catch this at 
compile time.  You can hint the MXML compiler, but not AS, and usually you 
stuff your AC from AS.

The only thing we do is throw an error at runtime.  I suppose you could wrap 
the whole thing, or copy the code and change signatures.

From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf 
Of burttram
Sent: Friday, December 12, 2008 11:15 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Best Practices: ArrayCollection of custom objects?


Is this such a trivial question that people are passing up replying
in lieu of bringing light to my ignorance, or are there really no best
practices to speak of here?

The only way I've found so far to do this is to deprecate the
overridden method, but even then from time to time we'll get a strange
error (this doesn't happen all of the time):

1021: Duplicate function definition.

Seems pretty obvious what's causing it, but we have other classes that
use this same syntax that aren't generating the error...

Is there any reason we shouldn't do this, or is there another, more
acceptable way to accomplish what we're trying to do here?

public class DataTypes extends ArrayCollection
{
public function DataTypes(){
}

[Deprecated]
override public function addItem(item:Object):void{
}

public function addItem(item:DataType):void{
super.addItem(item);
}
}

Reply via email to