The script is pretty much the stock script that macrodobe supply, with the
exception that I added the autoSize=true property to the textField that is
created.

One point I did notice is that this Cellrender extends UIComponent, where as
the cellrenderer that Alessandro Crugnola uses here:
http://www.sephiroth.it/tutorials/flashPHP/custom_tree/page002.php extends
mx.controls.treeclasses.TreeRow - is there a reason why he does this?

Here it is anyway:

[AS]
class MultiLineCell extends mx.core.UIComponent
{
        private var multiLineLabel;     // The label to be used for text.
        private var owner;                              // The row that
contains this cell.
        private var listOwner;                  // The List/grid/tree that
contains this cell.
        private static var PREFERRED_HEIGHT_OFFSET = 4;
        private static var PREFERRED_WIDTH = 100;
        private var startDepth:Number = 1;

        public function MultiLineCell()
        {
        }

        public function createChildren():Void
        {
                // The createLabel method is a useful method of UIObject and
a handy way to make labels in components.
                var c = multiLineLabel = this.createLabel("multiLineLabel",
startDepth);
                // Links the style of the label to the style of the grid
                c.styleName = listOwner;
                c.selectable = false;
                c.tabEnabled = false;
                c.background = false;
                c.border = false;
                c.multiline = true;
                c.wordWrap = true;
                c.autoSize = true;
        }

        public function size():Void
        {
                var c = multiLineLabel;
                c.setSize(__width, __height);
        }

        // Provides the preferred height of the cell.  Inherited method.
        public function getPreferredHeight():Number
        {

                return owner.__height;// - PREFERRED_HEIGHT_OFFSET;
        }

        // Called by the owner to set the value in the cell.  Inherited
method.
        public function setValue(suggestedValue:String, item:Object,
selected:Boolean):Void
        {
                if (item==undefined){
                        multiLineLabel.text._visible = false;
                }
                multiLineLabel.text = suggestedValue;
        }

}
[/AS]

Darren

-----Original Message-----
From: Mark Mulhollam [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, 23 August 2006 3:30 PM
To: Flashcoders mailing list
Subject: RE: [Flashcoders] Multiline text in a Tree Component

You should post your cellRenderer script.

Mark 

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Darren Bowers
Sent: Tuesday, August 22, 2006 11:07 AM
To: Flashcoders mailing list
Subject: [Flashcoders] Multiline text in a Tree Component


Hi all,
 
I am having a major pain implementing a multiline textfield in a Tree
component using the Cellrenderer API.
 
I am using the basic multiline code framework from Macrodobe here:
ttp://www.adobe.com/support/documentation/en/flash/fl8/samples.html
<http://www.adobe.com/support/documentation/en/flash/fl8/samples.html> 
 
If I set the textfield autoSize property in the cell, 90% of all text fields
will auto-size and auto-centre vertically properly. But for some strange
reason, there are a bunch that dont centre. They are usually off by about
5px. Some you can actually see drop when the cell re-renders. I am sure it
is something to do with the textfields reporting an incorrect height size
after the text is applied to the textfield, but i am having a nightmare
figuring out how to code around it.
 
Here is an example of what happens:
http://www.3ddu.org/test/treeViewComponent.html
<http://www.3ddu.org/test/treeViewComponent.html> 
 
Has anyone got an elegant solution to a multiline cellrenderer that centers
vertically or a hint on where to look to solve this?
 
Thanks,
Darren
 

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training http://www.figleaf.com
http://training.figleaf.com
----------------------------------------------------------------------------
CAUTION & DISCLAIMER: The information contained in this e-mail message
and/or any accompanying data or documents contain information that is 
confidential and subject to legal privilege. The information is intended
only for the recipient named in this message. The sender is excluded from
any liability arising from any further use, dissemination, distribution,
transmission or copying of this information and /or accompanying data by
the recipient. If you are not the intended recipient, you must immediately
erase the information along with all copies of this message and accompanying
data and notify the sender. Views expressed in this message are those of the
original sender, and are not necessarily the views of WestOne Services.
----------------------------------------------------------------------------

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to