1 Reply Latest reply on Jan 31, 2012 8:35 AM by salamaynasi

    Cant center image in cellfield

    salamaynasi Level 1

      I have written the following component to display an image when condition is satisfied following directions here

      It works but the image doesnt center in the cell of my datagrid. Is there any way I could center my image?

       

      package scalComponents

      {

                // scalComponents/CellField.as

                import mx.controls.*;

                import mx.controls.advancedDataGridClasses.AdvancedDataGridListData;

                import mx.core.*;

       

                public class CellField extends Image

                {

                          // Define the constructor and set properties.

                          public function CellField() {

                                    super();

                                    height=20;

                                    width=50;

                          }

                          // Override the set method for the data property.

                          override public function set data(value:Object):void

                          {

       

                                    var dataPresent:int

                                    if (value != null)

                                    {

                                              dataPresent = value[AdvancedDataGridListData(listData).dataField];

                                              if(dataPresent>=1)

                                              {

                                                        source='assets/gtk-yes.png'

                                                        //source='assets/tick20.png'

                                              }

                                              else

                                              {

                                                        source='assets/nothing.png'

                                              }

                                    }

       

                                    else

                                    {

                                              // If value is null, display nothing.

                                              //source='assets/nothing.png'

                                    }

       

                                    super.invalidateDisplayList();

                          }

                }

      }

        • 1. Re: Cant center image in cellfield
          salamaynasi Level 1

          dataPresent = value[AdvancedDataGridListData(listData).dataField];

                                                  if(dataPresent>=1)

                                                  {

                                                           setStyle("horizontalAlign", "center");

                                                            source='assets/gtk-yes.png'

                                                  }