开发者

Get text from a reapeater object - flex

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=开发者_JAVA技巧"animalid"/>


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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜