The answer is:  Generally, yes, subclasses can add or modify arguments.
But in scenarios where you are passing a class around to be instantiated
by other code, your class constructor needs to conform to whatever
contract is defined by that code.

 

In this case, the contract defined by charts is a little different.
They don't get passed a Class, but rather an implementation of IFactory.
Normally, you specify the class in MXML, and the compiler automatically
creates that instance for you. But you could create your own instance of
IFactory that does whatever it wants. For example, you could write an
IFactory implementation that has a 'color' property which it passes to
the constructor it instantiates.



Ely.

 

 

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of barry.beattie
Sent: Thursday, September 06, 2007 11:27 PM
To: [email protected]
Subject: [flexcoders] constructors in extended components: can they take
arguments?

 

the docs seem to hint "no" because (in this case) it changes the
signature from the base class ... but I just need to check.

within a chart I'm using the itemRenderer for each series in a BarSet.
I need some way to tell it that it's processing a different series
than the one before so it'll use a different fill colour. Passing in a
simple number from the MXML would be so handy here...

public class LabeledRenderer2 extends UIComponent implements
IDataRenderer
{
...
public function LabeledRenderer2():void
{
super();
_label = new Label();
addChild(_label);
_label.setStyle("color", 0xFFFFFF); 
}

 

<<image001.jpg>>

<<image002.jpg>>

Reply via email to