4 Replies Latest reply on Jun 14, 2012 7:38 AM by pjlumby

    Null data on dataChange event

    pjlumby

      I have a custom ItemRenderer that utilizes the dataChange event to calculate various bits and bobs when the data changes, it works fine the first time the data is loaded but the second time it gives me a;

       

      TypeError: Error #1009: Cannot access a property or method of a null object reference

       

      I dismiss it and it works fine from then on...

       

      <?xml version="1.0" encoding="utf-8"?>

      <s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"

                                              xmlns:s="library://ns.adobe.com/flex/spark"

                                              xmlns:mx="library://ns.adobe.com/flex/mx"

                                              autoDrawBackground="true" dataChange="init()">

       

                <fx:Script>

                          <![CDATA[

                                    import mx.controls.Alert;

                                    import mx.controls.ToolTip;

                                    import mx.core.DragSource;

                                    import mx.core.IUIComponent;

                                    import mx.events.DragEvent;

                                    import mx.events.FlexEvent;

                                    import mx.events.ResizeEvent;

                                    import mx.managers.DragManager;

                                    import mx.managers.ToolTipManager;

       

                                    import spark.components.BorderContainer;

                                    import spark.components.Image;

                                    import spark.primitives.BitmapImage;

                                    import spark.primitives.Ellipse;

       

                                    protected function init():void

                                    {

                                              switch (data.product_style_description)

                                              {

       

      It is at the  switch (data.product_style_description) line where it throws the error, I have used debugged the code and I seem to have that data... any help would be much appreciated.

       

      Pete