Skip navigation
Currently Being Moderated

Spark List ItemRenderer 'data' is null.

Jun 21, 2013 8:26 AM

Tags: #list #itemrenderer #spark #dataprovider #null

I'm using the exact same code in one location that I use in another, and yet upon the creationComplete event being dispatched within the itemRenderer, the first line of code, trace("data") returns "null".

 

This code has been working fine for months and suddenly stopped working with no explanation.  I've lost two days under deadline fixing what shouldn't be broken and I'm no closer to a solution.  Very frustrated. Any help -greatly- appreciated.

 

// Puddleglum.

 

=== Component relevant code containing spark list === Console output shown as comments

[Bindable]

public var itemArray:ArrayCollection = new ArrayCollection();

 

[Bindable]

private var gap:uint = 6;

 

private var file:File;

private var fileStream:FileStream;

private var toolXML:XML;

 

protected function creationCompleteHandler():void

{

    trace("MyLibraryToolsPanel FUNCTION creationCompleteHandler()");

    file = parentApplication.getFileOperations().getToolFilepath();

    trace("file: "+file.url);

}

 

private function loadTool(xmlFilepath:File, xmlFilename:String):void

{

    trace("MyLibraryToolsPanel FUNCTION loadTool("+xmlFilepath.url+", "+xmlFilename+")"); // MyLibraryToolsPanel FUNCTION loadTool(app-storage:/User000000/Tools, 000000Tool1371827886983.xml)

 

    var xmlFile:File = xmlFilepath.resolvePath(xmlFilename);

 

    if(xmlFile.exists)

    {

        fileStream = new FileStream();

        fileStream.open(xmlFile, FileMode.READ);

        toolXML = XML(fileStream.readUTFBytes(fileStream.bytesAvailable));

        fileStream.close();

 

        var obj:Object = new Object();

        obj.xmlFilepath = xmlFilepath;

        obj.xmlFilename = xmlFilename;

        obj.xml = toolXML;

        trace("obj: "+obj); // obj: [object Object]

        // trace("MyLibraryToolsPanel FUNCTION loadTool\n"+obj.xml.toXMLString());   // returns the XML when uncommented

 

        itemArray.addItemAt(obj, itemArray.length);

}

else

{

    trace("MyLibraryToolsPanel FUNCTION loadTool XMLFILE DOES NOT EXIST");  // This never triggers

}

 

<s:List id="itemList"

    useVirtualLayout="false"

    changing="listChangingHandler(event)"

    click="event.stopPropagation();"

    touchTap="event.stopPropagation();"

    scrollSnappingMode="leadingEdge"

    height="{height}"

    interactionMode="touch"

    explicitHeight="{height}"

    dropEnabled="false"

    dragEnabled="false"

    dragMoveEnabled="false"

    allowMultipleSelection="false"

    alternatingItemColors="[0xe6e6fa,0xF0F8ff]"

    dataProvider="{itemArray}"

    itemRenderer="renderers.MyLibraryToolsPanelListItemRenderer"

    horizontalScrollPolicy="off"

    verticalScrollPolicy="on"

    borderVisible="false"

    visible="{itemArray.length > 0}"

    includeInLayout="{itemList.visible}"

    width="100%">

 

    <s:layout>

        <s:VerticalLayout id="itemListVerticalLayout" variableRowHeight="false" gap="0"/>

    </s:layout>

</s:List>

 

 

<s:Label id="noToolsMsg" text="No saved tools available." horizontalCenter="0" verticalAlign="middle" verticalCenter="0" visible="{itemArray.length == 0}" includeInLayout="{noToolsMsg.visible}"/>

</s:Group>

 

=== Renderer code containing relevant sections ===

protected function creationCompleteHandler():void

{

    trace("MyLibraryToolsPanelListItemRenderer FUNCTION creationCompleteHandler"); // MyLibraryToolsPanelListItemRenderer FUNCTION creationCompleteHandler

    trace("data: "+data);  // data: null

 

    dataProxy = new ObjectProxy(data);

...

 
Replies

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points