views:

148

answers:

1

I have a label that is using a repeater to get information form a database. Now I'm trying to pass the information in that label to another label component, but I haven't had any luck.

if I do a trace on the label in the repeater eg.

trace (Gotid.text);

I get this error in debug mode

warning: unable to bind to property 'user_name' on class 'Object' (class is not an IEventDispatcher) undefined

Any ideas on how I go about getting information form Gotid to display as text in another label?

  • k I'll try to make this as straight forward as possible

        private function Getid():void {
        var stmt:SQLStatement = new SQLStatement();
        stmt.sqlConnection = sqlConn;
        stmt.text = "SELECT * FROM tbl_animal WHERE animal_ptag='"+ptagInput.text+"'"; 
        stmt.execute();
        var result:SQLResult = stmt.getResult();
        acGetid = new ArrayCollection(result.data);
        animalid.text = Gotid.text;
        trace (Gotid.text);
    }
    

-

    <mx:Repeater id="getidrepeater" dataProvider="{acGetid}">
<mx:Label x="30" y="362" text="{getidrepeater.currentItem.animal_id}" id="Gotid"/>  
</mx:Repeater>
<mx:Label x="30" y="388" text="Label" id="animalid"/>
A: 

I'm not sure how it relates to your user_name error, but the Gotid field in your main component will be an array of Labels, not a single Label field.

See Referencing Repeated Components in this Adobe Docs page, for example.

Given that you're possibly getting multiple animals to fill in Gotid with, I don't know how you know which to fill in the animalid label. If you assume you're only going to get one, you could do:

animalid.text = Gotid[0].text;
trace (Gotid[0].text);
Michael Brewer-Davis
Thanks, That seem to do what I was looking for. Is there a better way to accomplish this instead of a repeater if I'm only looking for one result?
Adam
I would probably get the data out of the SQLResult (`result.data[0]`) and use that to fill in a single UI component; you're going to have to deference the array somewhere, but at least the data knows it's supposed to be a single result.
Michael Brewer-Davis
Thanks for the insight!
Adam