>>inherited functions aren't automatically
>>called (except in the case of no-arg constructors).
Well, not true as I understand it in inheritance, it depends
on what it
inherits from - i.e., if I put a trace in setValue in my
class, compile
my file, the method fires every time the checkbox is cliked
in the
datagrid cell - I make no calls to super. Here is my
class:
import mx.controls.CheckBox;
class com.boa.projects.iqrcgenerator.components.CheckBoxCell
extends
mx.core.UIComponent
{
private var owner; // The row that contains this cell.
private var listOwner; // The List, data grid or tree
containing
this cell.
private var cb; //the checkbox instance
private static var PREFERRED_HEIGHT_OFFSET = 4; // Cell
height
offset from the row height total & preferred cell
width.
private static var PREFERRED_WIDTH = 100;
private var startDepth:Number = 1; // Starting depth.
public function CheckBoxCell()
{
}
public function createChildren():Void
{
cb = this.createClassObject(mx.controls.CheckBox,
"cb",
1);
cb.addEventListener("click", this);
size();
}
public function size():Void
{
cb.setSize(__width, __height);
cb._x = (__width-20)/2;
cb._y = (__height-16)/2;
}
public function getPreferredHeight():Number
{
return owner.__height - PREFERRED_HEIGHT_OFFSET;
}
function setValue(str:String, item:Object, sel:Boolean) :
Void
{
cb._visible = (item!=undefined);
if(item[getDataLabel()] == "Y") { cb.selected =
true }
else { cb.selected = false };
}
};
Jason Merrill
Bank of America
Learning & Organizational Effectiveness
>>-----Original Message-----
>>From: osflash-bounces osflash.org
>>[mailto:osflash-bounces osflash.org] On Behalf Of
Ian Thomas
>>Sent: Tuesday, February 20, 2007 4:19 PM
>>To: Open Source Flash Mailing List
>>Subject: Re: [osflash] OT: CellRenderer API &
setValue
>>
>>My assumption was that you were wanting to update
the
>>underlying value stored in your dataProvider - thus
fixing
>>the problem with the rendering. Am I wrong? It looks
a bit to
>>me like your code is correctly rendering what's
stored in
>>dataProvider, but clicking on your checkbox doesn't
actually
>>_alter_ what's in dataProvider, which is where your
problem
>>is coming from. And, randomly guessing, I'd guess
that needs
>>to be done in dataProvider.
>>
>>You say "Already being done as this is an
inherited
>>function." with regards to calling your
superclasses version
>>of setValue(). Not sure I understand how that
happens in the
>>code you supplied - inherited functions aren't
automatically
>>called (except in the case of no-arg constructors).
You'd
>>generally need to call:
>>
>>// overriding function
>>function myFunction():Void
>>{
>> // call parent implementation
>> super.myFunction();
>> // do extra stuff here
>> . . .
>>}
>>
>>to make sure your superclass gets a chance to act.
But then I
>>don't know whether your superclass does anything
sensible
>>with setValue either.
>>
>>Don't really know what your setup is - just making a
few
>>guesses, so may be way off-base!
>>
>>Ian
>>
>>On 2/20/07, Merrill, Jason <jason.merrill bankofamerica.com> wrote:
>>> Thanks for your respone. Explain what you mean
by,
>>"underlying value" ?
>>>
>>>
>>> I am setting the checkbox to be checked or not
by doing:
>>>
>>> if(item[getDataLabel()] == "Y") {
cb.selected = true } else {
>>> cb.selected = false };
>>>
>>> >> Perhaps you need to call the
superclass version of
>>> >>setValue() somewhere in there?
>>>
>>> Already being done as this is an inherited
function. I am
>>getting the
>>> label of the current cell and using that to
select the
>>checkbox. But
>>> this probably shouldn't be done inside this
function as the
>>setValue
>>> function is called every time the datagrid cell
is
>>interacted with.
>>> Not sure how this is normally done, and how to
do this
>>better, this is
>>> my first experience with the CellRenderer API.
Thanks for
>>any advice.
>>>
>>> Jason Merrill
>>> Bank of America
>>> Learning & Organizational Effectiveness
>>>
>>
>>_______________________________________________
>>osflash mailing list
>>osflash osflash.org
>>http://osflash.org/mailman/listinfo/osflash_osflash.org
a>
>>
_______________________________________________
osflash mailing list
osflash osflash.org
http://osflash.org/mailman/listinfo/osflash_osflash.org
a>
|