Posts tagged ‘actionscript’

Item renderer in ActionScript

package myComponents {

    // myComponents/CellField.as
    import mx.controls.*;
    import mx.core.*;
    import mx.controls.dataGridClasses.DataGridListData;

    public class CellField extends TextInput

    {
        // Define the constructor and set properties.
        public function CellField() {
            super();
            height=60;
            width=80;
            setStyle("borderStyle", "none");
            editable=false;
        }

        // Override the set method for the data property.
        override public function set data(value:Object):void {

            super.data = value;

            if (value != null)

            {
                text = value[DataGridListData(listData).dataField];
                if(Number(text) > 100)

                {
                    setStyle("backgroundColor", 0xFF0000);
                }
            }

            else
            {
                // If value is null, clear text.
                text= "";
            }

            super.invalidateDisplayList();
        }

    }
}