Flex bind metadata

Source: Internet
Author: User

This is a way to bind images or Flash files to Data. In Code Medium:
[Bindable]
[Embed ("assets/closed.png")]
Public var myfolderclosedicon: class;
The three lines of code bind clsed.png to available data.
[Embed (...)] is called "metadata"
Then, just follow the instructions to define a classvariable. This classcode represents the closed.png element.
Finally, let's look at the call in mxml:
Folderclosedicon = "{myfolderclosedicon }"
We can see that the tree component directly calls this class as the ICO icon before the node closure in the tree.
You can also use the "meta tag" [mx: Metadata] to bind metadata.
The Code analyzed in this article is as follows: [the function of this code segment is to change the tree component list icon ICO] Copy code The Code is as follows: <? XML version = "1.0" encoding = "UTF-8"?>
<Mx: Application xmlns: MX = "http://www.adobe.com/2006/mxml"
Layout = "horizontal" viewsourceurl = "srcview/index.html">
<Mx: SCRIPT>
<! [CDATA [

[Bindable]
[Embed ("http://longstep.cn/closed.png")]
Public var myfolderclosedicon: class;
[Bindable]
[Embed ("http://longstep.cn/opened.png")]
Public var myfolderopenicon: class;

[Bindable]
[Embed ("http://longstep.cn/pdf.png")]
Public var pdficon: class;
[Bindable]
[Embed ("http://longstep.cn/doc.png")]
Public var docicon: class;

]>
</MX: SCRIPT>
<Mx: XML id = "xmldata" xmlns = "">
<Rootnode>
<Directory label = "dir">
<File icon = "pdficon" label = "label1"/>
<File icon = "docicon" label = "label2"/>
</Directory>
<Directory label = "dir1">
<File icon = "pdficon" label = "label3"/>
<File icon = "docicon" label = "label4"/>
</Directory>
</Rootnode>
</MX: XML>
<Mx: panel title = "Tree">

<Mx: Tree
Borderstyle = "NONE"
Backgroundalpha = "0"
Labelfield = "@ label"
Iconfield = "@ icon"
Width = "300"
Height = "200"
Id = "treeadmin"
Folderopenicon = "{myfolderopenicon }"
Folderclosedicon = "{myfolderclosedicon }"
Dataprovider = "{xmldata. Directory}" alpha = "1"/>
</MX: Panel>
</MX: Application>

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.