Hi,

responding to the first question;

Why not use styles for that? We as developers need to understand there are 3
interfaces into a UIComponent.

1. Events
2. Styles
3. Class API

With that said, dealing with your example class;


public class LabeledRenderer2 extends UIComponent implements IDataRenderer
{
...
public function LabeledRenderer2():void
{
   super();
}

override protected function createChildren():void
{
   super.createChildren();

    _label = new Label();
    _label.styleName = this;
    addChild(_label);

}
}

Then you can use this to default and also have the ability to change things
a runtime in a cascading way.

LabeledRenderer2 {
   color:#FFFFFF;
   fontWeight:"bold";
   etc...
}

or

var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration("");
style.setStyle("color", 0x242424);

Is the right way to do it.

Keep in mind, when you develop a lot you will more than likely someday reuse
this code.

This is utilizing the the Style interface the way it should in a balanced
way.

Peace, Mike

On 9/7/07, Ely Greenfield <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
>
>
> 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:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On
> Behalf Of *barry.beattie
> *Sent:* Thursday, September 06, 2007 11:27 PM
> *To:* flexcoders@yahoogroups.com
> *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);
> }
>
>   
>
>


-- 
Teoti Graphix
http://www.teotigraphix.com

Blog - Flex2Components
http://www.flex2components.com

You can find more by solving the problem then by 'asking the question'.

Reply via email to