0

here is a flex newbie. I've tested the 'answer 2' code from

Connecting Flex to SQLite

but I modified it: throwed in a button, which purpose is to populate the list with data, after being clicked; result is half-success, got back "[object Object]" in the list instead of data; how to overcome this problem? Flex is 4.6, the code follows:

<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
    xmlns:s="library://ns.adobe.com/flex/spark" 
    title="">
<fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:layout>
    <s:VerticalLayout paddingTop="10" paddingLeft="10"/>
</s:layout>
<fx:Script>

    <![CDATA[
        import flash.data.SQLConnection;
        import flash.data.SQLStatement;
        import flash.filesystem.File;
        import flash.filesystem.FileMode;

        import mx.collections.ArrayCollection;
        private function getData():ArrayCollection 
        {
            var stmt:SQLStatement = new SQLStatement();
            stmt.sqlConnection = new SQLConnection();

            stmt.sqlConnection.open(File.applicationStorageDirectory.resolvePath("assets/test.sqlite"));
            stmt.text = "SELECT one, two FROM zero";
            stmt.execute();
            var result:Array = stmt.getResult().data;
            resultArr =  new ArrayCollection();
            if (result)
            {      
                resultArr.source = result;           
            }
        return resultArr;
        }
        [Bindable]private var resultArr:ArrayCollection = new ArrayCollection();

        protected function button1_clickHandler(event:MouseEvent):void
        {
            // TODO Auto-generated method stub
            getData();
        }

    ]]>
</fx:Script>
<s:Button label="OK" click="button1_clickHandler(event)"/>
<s:List width="302" height="234" dataProvider="{resultArr}"></s:List>
</s:View>

Thanks to whoever wants to help me.

Community
  • 1
  • 1
shazbat
  • 1
  • 1

1 Answers1

0

Your getting the [object Object] because the data that is being returned has multiple values (columns one and two). You will need to tell the application what it is that you want displayed.

Try setting the labelField parameter and see what you get:

<s:List width="302" height="234" dataProvider="{resultArr}" labelField="one"></s:List>
Nate
  • 2,881
  • 1
  • 14
  • 14
  • No prob, if it is correct, flag it as answered so other people can trust it :) – Nate Jun 08 '12 at 16:41
  • Next to the answer where there are up / down arrows and a number, you should have an area to mark it as accepted. :) – Nate Jun 08 '12 at 16:46