<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Flex Examples &#187; localName()</title>
	<atom:link href="http://blog.flexexamples.com/tag/localname/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexexamples.com</link>
	<description>Just a bunch of Adobe Flex Examples</description>
	<lastBuildDate>Wed, 26 Jan 2011 18:09:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Defining a custom label function on a Flex Tree control</title>
		<link>http://blog.flexexamples.com/2007/10/29/defining-a-custom-label-function-on-a-flex-tree-control/</link>
		<comments>http://blog.flexexamples.com/2007/10/29/defining-a-custom-label-function-on-a-flex-tree-control/#comments</comments>
		<pubDate>Tue, 30 Oct 2007 06:28:21 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[E4X]]></category>
		<category><![CDATA[Tree]]></category>
		<category><![CDATA[labelFunction]]></category>
		<category><![CDATA[localName()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2007/10/29/defining-a-custom-label-function-on-a-flex-tree-control/</guid>
		<description><![CDATA[<p>The following example shows how you can specify a custom label function on a Tree control in Flex where the returned label is specific to the node name.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Tree_labelFunction_test/main.mxml">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2007/10/29/defining-a-custom-label-function-on-a-flex-tree-control/ --&#62; &#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white"&#62; &#60;mx:Script&#62; &#60;![CDATA[ private function tree_labelFunc(item:XML):String { [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can specify a custom label function on a Tree control in Flex where the returned label is specific to the node name.</p>
<p>Full code after the jump.</p>
<p><span id="more-258"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Tree_labelFunction_test/main.mxml">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2007/10/29/defining-a-custom-label-function-on-a-flex-tree-control/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            private function tree_labelFunc(item:XML):String {
                var label:String;
                switch (item.localName()) {
                    case "league":
                        label = item.@title;
                        break;
                    case "team":
                        label = item.@name;
                        break;
                    case "stadium":
                        label = item.name;
                }
                return label;
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:XML id="mlb" source="mlb.xml" /&gt;

    &lt;mx:Tree id="tree"
            dataProvider="{mlb.league}"
            labelFunction="tree_labelFunc"
            width="300"
            rowCount="8" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Tree_labelFunction_test/mlb.xml">View mlb.xml</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2007/10/29/defining-a-custom-label-function-on-a-flex-tree-control/ --&gt;
&lt;mlb&gt;
    &lt;league id="al" title="American League"&gt;
        &lt;team name="Baltimore Orioles" /&gt;
        &lt;team name="Boston Red Sox" /&gt;
        &lt;team name="Chicago White Sox" /&gt;
        &lt;team name="Cleveland Indians" /&gt;
        &lt;team name="Detroit Tigers" /&gt;
        &lt;team name="Kansas City Royals" /&gt;
        &lt;team name="Los Angeles Angels of Anaheim" /&gt;
        &lt;team name="Minnesota Twins" /&gt;
        &lt;team name="New York Yankees" /&gt;
        &lt;team name="Oakland Athletics" /&gt;
        &lt;team name="Seattle Mariners" /&gt;
        &lt;team name="Tampa Bay Devil Rays" /&gt;
        &lt;team name="Texas Rangers" /&gt;
        &lt;team name="Toronto Blue Jays" /&gt;
    &lt;/league&gt;
    &lt;league id="nl" title="National League"&gt;
        &lt;team name="Arizona Diamondbacks" /&gt;
        &lt;team name="Atlanta Braves" /&gt;
        &lt;team name="Chicago Cubs" /&gt;
        &lt;team name="Cincinnati Reds" /&gt;
        &lt;team name="Colorado Rockies" /&gt;
        &lt;team name="Florida Marlins" /&gt;
        &lt;team name="Houston Astros" /&gt;
        &lt;team name="Los Angeles Dodgers" /&gt;
        &lt;team name="Milwaukee Brewers" /&gt;
        &lt;team name="New York Mets" /&gt;
        &lt;team name="Philadelphia Phillies" /&gt;
        &lt;team name="Pittsburgh Pirates" /&gt;
        &lt;team name="San Diego Padres" /&gt;
        &lt;team name="San Francisco Giants" /&gt;
        &lt;team name="St. Louis Cardinals" /&gt;
        &lt;team name="Washington Nationals" /&gt;
    &lt;/league&gt;
&lt;/mlb&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/Tree_labelFunction_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/Tree_labelFunction_test/bin/main.html" width="100%" height="300"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Defining a custom label function on a Flex Tree control on FlexExamples.com',url: 'http://blog.flexexamples.com/2007/10/29/defining-a-custom-label-function-on-a-flex-tree-control/',contentID: 'post-258',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'labelFunction,localName()',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2007/10/29/defining-a-custom-label-function-on-a-flex-tree-control/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>

