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>