Binding arraycollection In Flex warning: Unable to bind to property

Source: Internet
Author: User

Reprinted: http://hi.baidu.com/exgeztfhdnbkmwd/item/5820201b17cae1fa9d778acc

In the development of FLEX, binding is often used, and the annoying thing is that the following warning constantly appears:

Warning: Unable to bind to property 'icon 'on class 'object' (class is not an ieventdispatcher)

So what should we do? Take the following example:

<? XML version = "1.0" encoding = "UTF-8"?>
<Mx: Application xmlns: MX = "http://www.adobe.com/2006/mxml" layout = "absolute">
<Mx: arraycollection id = "arrcoll">
<Mx: Source>
<Mx: array id = "arr">
<Mx: Object Data = "0" label = "icon =" img/0.gif"/>
<Mx: Object Data = "1" label = "icon =" img/1.gif"/>
<Mx: Object Data = "2" label = "icon =" img/2.gif"/>
<Mx: Object Data = "3" label = "icon =" img/3.gif"/>
<Mx: Object Data = "4" label = "icon =" img/4.gif"/>
<Mx: Object Data = "5" label = "icon =" img/5.gif"/>

</MX: array>
</MX: Source>
</MX: arraycollection>
<Mx: popupbutton id = "popupbutton_pic" openalways = "true" width = "43" Height = "23">
<Mx: popup>
<Mx: titlewindow id = "titlewindow_popup" width = "450" Height = "400"
Showclosebutton = "true" verticalscrollpolicy = "on" horizontalscrollpolicy = "off" Close = "popupbutton_pic.close ();">
<Mx: toolbar width = "430">
<Mx: repeater id = "myrep" dataprovider = "{arrcoll}">
<Mx: Image id = "myimgclick" buttonmode = "true" Data = "{myrep. currentindex}" Source = "{myrep. currentitem. Icon}">
</MX: Image>
</MX: repeater>
</MX: toolbar>
</MX: titlewindow>
</MX: popup>
</MX: popupbutton>
</MX: Application>

The above example is run without errors, but there are many warnings (such as), because objet is not of the ieventdispatcher type.

The solution is as follows:

<? XML version = "1.0" encoding = "UTF-8"?>
<Mx: Application xmlns: MX = "http://www.adobe.com/2006/mxml" layout = "absolute" xmlns: Local = "*">
<Mx: arraycollection id = "arrcoll">
<Mx: Source>
<Mx: array id = "arr">
<Local: mycls DATA = "0" label = "" icon = "img/0.gif"/>
<Local: mycls DATA = "1" label = "" icon = "img/1.gif"/>
<Local: mycls DATA = "2" label = "" icon = "img/2.gif"/>
<Local: mycls DATA = "3" label = "" icon = "img/3.gif"/>
<Local: mycls DATA = "4" label = "" icon = "img/4.gif"/>
<Local: mycls DATA = "5" label = "" icon = "img/5.gif"/>

</MX: array>
</MX: Source>
</MX: arraycollection>
<Mx: popupbutton id = "popupbutton_pic" openalways = "true" width = "43" Height = "23">
<Mx: popup>
<Mx: titlewindow id = "titlewindow_popup" width = "450" Height = "400"
Showclosebutton = "true" verticalscrollpolicy = "on" horizontalscrollpolicy = "off" Close = "popupbutton_pic.close ();">
<Mx: toolbar width = "430">
<Mx: repeater id = "myrep" dataprovider = "{arrcoll}">
<Mx: Image id = "myimgclick" buttonmode = "true" Data = "{myrep. currentindex}" Source = "{myrep. currentitem. Icon}">
</MX: Image>
</MX: repeater>
</MX: toolbar>
</MX: titlewindow>
</MX: popup>
</MX: popupbutton>
</MX: Application>

Mycls.:

Package
{
[Bindable]
Public class mycls
{
Public var data: string;
Public var TP: string;
Public var label: string;
Public var icon: string;
Public Function mycls ()
{
}

}
}

Through the above method, you can easily solve the binding problem, and this method is called "class binding method ".

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.