<?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; children</title>
	<atom:link href="http://blog.flexexamples.com/tag/children/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>Creating three related Spark DropDownList controls in Flex 4</title>
		<link>http://blog.flexexamples.com/2010/01/28/creating-three-related-spark-dropdownlist-controls-in-flex-4/</link>
		<comments>http://blog.flexexamples.com/2010/01/28/creating-three-related-spark-dropdownlist-controls-in-flex-4/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 20:58:24 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[beta2]]></category>
		<category><![CDATA[DropDownList (Spark)]]></category>
		<category><![CDATA[children]]></category>
		<category><![CDATA[dataProvider]]></category>
		<category><![CDATA[Gumbo]]></category>
		<category><![CDATA[selectedItem]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/?p=2348</guid>
		<description><![CDATA[<p>In a previous example, <a href="http://blog.flexexamples.com/2007/08/04/creating-two-related-comboboxes/">&#8220;Creating two related ComboBoxes&#8221;</a>, we saw how you could create two or three related MX ComboBox controls in Flex 3 by binding to the previous ComboBox control&#8217;s selected item.</p> <p>The following example shows how you can create three related Spark DropDownList controls in Flex 4 by using databinding and XML.</p> [...]]]></description>
			<content:encoded><![CDATA[<p>In a previous example, <a href="http://blog.flexexamples.com/2007/08/04/creating-two-related-comboboxes/">&#8220;Creating two related ComboBoxes&#8221;</a>, we saw how you could create two or three related MX ComboBox controls in Flex 3 by binding to the previous ComboBox control&#8217;s selected item.</p>
<p>The following example shows how you can create three related Spark DropDownList controls in Flex 4 by using databinding and XML.</p>
<p><span id="more-2348"></span></p>
<p class="alert">The following example(s) require Flash Player 10 and the Adobe Flex 4 SDK. To download the Adobe Flash Builder 4 trial, see <a href="http://bit.ly/crThlI">http://www.adobe.com/products/flex/</a>. To download the latest nightly build of the Flex 4 SDK, see <a href="http://bit.ly/Flex4SDK">http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4</a>.<br/><strong>For more information on getting started with Flex 4 and Flash Builder 4, see the official <a href="http://bit.ly/dCkecm">Adobe Flex Team blog</a>.</strong></p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- http://blog.flexexamples.com/2010/01/28/creating-three-related-spark-dropdownlist-controls-in-flex-4/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Application</span> name=<span style="color: #ff0000;">&quot;Spark_DropDownList_related_test&quot;</span></span>
<span style="color: #000000;">        xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span></span>
<span style="color: #000000;">        xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span></span>
<span style="color: #000000;">        xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/mx&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:XMLListCollection</span> id=<span style="color: #ff0000;">&quot;dp&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:XMLList</span> xmlns=<span style="color: #ff0000;">&quot;&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;">&lt;country label=<span style="color: #ff0000;">&quot;USA&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                    <span style="color: #000000;">&lt;state label=<span style="color: #ff0000;">&quot;Alaska&quot;</span> city=<span style="color: #ff0000;">&quot;AK&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                        <span style="color: #000000;">&lt;city label=<span style="color: #ff0000;">&quot;Anchorage&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;">&lt;city label=<span style="color: #ff0000;">&quot;Fairbanks&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;">&lt;city label=<span style="color: #ff0000;">&quot;Juneau&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                    <span style="color: #000000;">&lt;/state<span style="color: #7400FF;">&gt;</span></span>
                    <span style="color: #000000;">&lt;state label=<span style="color: #ff0000;">&quot;California&quot;</span> abbr=<span style="color: #ff0000;">&quot;CA&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                        <span style="color: #000000;">&lt;city label=<span style="color: #ff0000;">&quot;San Francisco&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;">&lt;city label=<span style="color: #ff0000;">&quot;Oakland&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;">&lt;city label=<span style="color: #ff0000;">&quot;Los Angeles&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;">&lt;city label=<span style="color: #ff0000;">&quot;Palm Springs&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;">&lt;city label=<span style="color: #ff0000;">&quot;Sacramento&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                    <span style="color: #000000;">&lt;/state<span style="color: #7400FF;">&gt;</span></span>
                    <span style="color: #000000;">&lt;state label=<span style="color: #ff0000;">&quot;Nevada&quot;</span> abbr=<span style="color: #ff0000;">&quot;NV&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                        <span style="color: #000000;">&lt;city label=<span style="color: #ff0000;">&quot;Las Vegas&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;">&lt;city label=<span style="color: #ff0000;">&quot;Reno&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;">&lt;city label=<span style="color: #ff0000;">&quot;Carson City&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                    <span style="color: #000000;">&lt;/state<span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;">&lt;/country<span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;">&lt;country label=<span style="color: #ff0000;">&quot;Canada&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                    <span style="color: #000000;">&lt;province label=<span style="color: #ff0000;">&quot;British Columbia&quot;</span>  abbr=<span style="color: #ff0000;">&quot;BC&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                        <span style="color: #000000;">&lt;city label=<span style="color: #ff0000;">&quot;Vancouver&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;">&lt;city label=<span style="color: #ff0000;">&quot;Victoria&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                    <span style="color: #000000;">&lt;/province<span style="color: #7400FF;">&gt;</span></span>
                    <span style="color: #000000;">&lt;province label=<span style="color: #ff0000;">&quot;Alberta&quot;</span> abbr=<span style="color: #ff0000;">&quot;AB&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                        <span style="color: #000000;">&lt;city label=<span style="color: #ff0000;">&quot;Calgary&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;">&lt;city label=<span style="color: #ff0000;">&quot;Edmonton&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                    <span style="color: #000000;">&lt;/province<span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;">&lt;/country<span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:XMLList</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:XMLListCollection</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Form</span> horizontalCenter=<span style="color: #ff0000;">&quot;0&quot;</span> top=<span style="color: #ff0000;">&quot;20&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span> label=<span style="color: #ff0000;">&quot;Country:&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:DropDownList</span> id=<span style="color: #ff0000;">&quot;countryDDL&quot;</span></span>
<span style="color: #000000;">                    dataProvider=<span style="color: #ff0000;">&quot;{dp}&quot;</span></span>
<span style="color: #000000;">                    labelField=<span style="color: #ff0000;">&quot;@label&quot;</span></span>
<span style="color: #000000;">                    requireSelection=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span> label=<span style="color: #ff0000;">&quot;State:&quot;</span> required=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:DropDownList</span> id=<span style="color: #ff0000;">&quot;stateDDL&quot;</span></span>
<span style="color: #000000;">                    dataProvider=<span style="color: #ff0000;">&quot;{new XMLListCollection(countryDDL.selectedItem.children())}&quot;</span></span>
<span style="color: #000000;">                    labelField=<span style="color: #ff0000;">&quot;@label&quot;</span></span>
<span style="color: #000000;">                    requireSelection=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span> label=<span style="color: #ff0000;">&quot;City:&quot;</span> required=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:DropDownList</span> id=<span style="color: #ff0000;">&quot;cityDDL&quot;</span></span>
<span style="color: #000000;">                    dataProvider=<span style="color: #ff0000;">&quot;{new XMLListCollection(stateDDL.selectedItem.children())}&quot;</span></span>
<span style="color: #000000;">                    labelField=<span style="color: #ff0000;">&quot;@label&quot;</span></span>
<span style="color: #000000;">                    requireSelection=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Form</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<div span="googleAdsLeaderboard">
<script type="text/javascript"><!--
google_ad_client = "pub-3325829455487492";
/* 728x90, created 7/15/09 */
google_ad_slot = "6403511741";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
</div>
<p class="information"><a href="http://dl.dropbox.com/u/4509565/FlexExamples_com/Spark_DropDownList_related_test/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://dl.dropbox.com/u/4509565/FlexExamples_com/Spark_DropDownList_related_test/main.html" width="100%" height="300"></iframe></p>
<p class="alert">This entry is based on a beta version of the Flex 4 SDK and therefore is very likely to change as development of the Flex SDK continues. The API can (and will) change causing examples to possibly not compile in newer versions of the Flex 4 SDK.</p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Creating three related Spark DropDownList controls in Flex 4 on FlexExamples.com',url: 'http://blog.flexexamples.com/2010/01/28/creating-three-related-spark-dropdownlist-controls-in-flex-4/',contentID: 'post-2348',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'children,dataProvider,Gumbo,selectedItem',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/2010/01/28/creating-three-related-spark-dropdownlist-controls-in-flex-4/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Using an XML data provider with the Spark List control in Flex 4</title>
		<link>http://blog.flexexamples.com/2009/11/04/using-an-xml-data-provider-with-the-spark-list-control-in-flex-4/</link>
		<comments>http://blog.flexexamples.com/2009/11/04/using-an-xml-data-provider-with-the-spark-list-control-in-flex-4/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 21:57:39 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[beta2]]></category>
		<category><![CDATA[List (Spark)]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[XMLList]]></category>
		<category><![CDATA[XMLListCollection]]></category>
		<category><![CDATA[children]]></category>
		<category><![CDATA[dataProvider]]></category>
		<category><![CDATA[Gumbo]]></category>
		<category><![CDATA[IList]]></category>
		<category><![CDATA[source]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/?p=2163</guid>
		<description><![CDATA[<p>The following example shows how you can use an XML document as a data provider for a Spark List control in Flex 4 by using an XMLListCollection.</p> <p>Full code after the jump.</p> <p></p> &#60;?xml version=&#34;1.0&#34;?&#62; &#60;!-- http://blog.flexexamples.com/2009/11/04/using-an-xml-data-provider-with-the-spark-list-control-in-flex-4/ --&#62; &#60;s:Application name=&#34;Spark_List_dataProvider_XML_test&#34; xmlns:fx=&#34;http://ns.adobe.com/mxml/2009&#34; xmlns:s=&#34;library://ns.adobe.com/flex/spark&#34; xmlns:mx=&#34;library://ns.adobe.com/flex/halo&#34;&#62; &#160; &#60;s:List id=&#34;lst&#34; labelField=&#34;@label&#34; horizontalCenter=&#34;0&#34; verticalCenter=&#34;0&#34;&#62; &#60;s:dataProvider&#62; &#60;s:XMLListCollection&#62; &#60;fx:XMLList xmlns=&#34;&#34;&#62; &#60;node label=&#34;One&#34; [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can use an XML document as a data provider for a Spark List control in Flex 4 by using an XMLListCollection.</p>
<p>Full code after the jump.</p>
<p><span id="more-2163"></span></p>
<p class="alert">The following example(s) require Flash Player 10 and the Adobe Flex 4 SDK. To download the Adobe Flash Builder 4 trial, see <a href="http://bit.ly/crThlI">http://www.adobe.com/products/flex/</a>. To download the latest nightly build of the Flex 4 SDK, see <a href="http://bit.ly/Flex4SDK">http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4</a>.<br/><strong>For more information on getting started with Flex 4 and Flash Builder 4, see the official <a href="http://bit.ly/dCkecm">Adobe Flex Team blog</a>.</strong></p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- http://blog.flexexamples.com/2009/11/04/using-an-xml-data-provider-with-the-spark-list-control-in-flex-4/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Application</span> name=<span style="color: #ff0000;">&quot;Spark_List_dataProvider_XML_test&quot;</span></span>
<span style="color: #000000;">        xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span></span>
<span style="color: #000000;">        xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span></span>
<span style="color: #000000;">        xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/halo&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:List</span> id=<span style="color: #ff0000;">&quot;lst&quot;</span></span>
<span style="color: #000000;">            labelField=<span style="color: #ff0000;">&quot;@label&quot;</span></span>
<span style="color: #000000;">            horizontalCenter=<span style="color: #ff0000;">&quot;0&quot;</span> verticalCenter=<span style="color: #ff0000;">&quot;0&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:dataProvider</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:XMLListCollection</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:XMLList</span> xmlns=<span style="color: #ff0000;">&quot;&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                    <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;One&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                    <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;Two&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                    <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;Three&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                    <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;Four&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                    <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;Five&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                    <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;Six&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                    <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;Seven&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                    <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;Eight&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                    <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;Nine&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:XMLList</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:XMLListCollection</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:dataProvider</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:List</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>Or, if you wanted to embed the XML into your application, you could use the &lt;fx:XML/&gt; tag and bind to an XMLListCollection, as seen in the following example:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- http://blog.flexexamples.com/2009/11/04/using-an-xml-data-provider-with-the-spark-list-control-in-flex-4/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Application</span> name=<span style="color: #ff0000;">&quot;Spark_List_dataProvider_XML_test&quot;</span></span>
<span style="color: #000000;">        xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span></span>
<span style="color: #000000;">        xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span></span>
<span style="color: #000000;">        xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/halo&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:XML</span> id=<span style="color: #ff0000;">&quot;nodes&quot;</span> source=<span style="color: #ff0000;">&quot;nodesAndStuff.xml&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:List</span> id=<span style="color: #ff0000;">&quot;lst&quot;</span></span>
<span style="color: #000000;">            labelField=<span style="color: #ff0000;">&quot;@label&quot;</span></span>
<span style="color: #000000;">            horizontalCenter=<span style="color: #ff0000;">&quot;0&quot;</span> verticalCenter=<span style="color: #ff0000;">&quot;0&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:dataProvider</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:XMLListCollection</span> source=<span style="color: #ff0000;">&quot;{nodes.children()}&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:dataProvider</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:List</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>And the external .XML file, <em>nodesAndStuff.xml</em>, is as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #808080; font-style: italic;">&lt;!-- http://blog.flexexamples.com/2009/11/04/using-an-xml-data-provider-with-the-spark-list-control-in-flex-4/ --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;root<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;node</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;One&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;node</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;Two&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;node</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;Three&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;node</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;Four&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;node</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;Five&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;node</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;Six&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;node</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;Seven&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;node</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;Eight&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;node</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;Nine&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/root<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Or, if you didn&#8217;t want to use data binding, <em>Corey</em>, you could set the data provider using ActionScript, as seen in the following example:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- http://blog.flexexamples.com/2009/11/04/using-an-xml-data-provider-with-the-spark-list-control-in-flex-4/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Application</span> name=<span style="color: #ff0000;">&quot;Spark_List_dataProvider_XML_test&quot;</span></span>
<span style="color: #000000;">        xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span></span>
<span style="color: #000000;">        xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span></span>
<span style="color: #000000;">        xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/halo&quot;</span></span>
<span style="color: #000000;">        initialize=<span style="color: #ff0000;">&quot;init();&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;">&lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span></span>
<span style="color: #000000;">            private function init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                xmlListColl.source = nodes.children<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#125;</span></span>
<span style="color: #000000;">        <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:XML</span> id=<span style="color: #ff0000;">&quot;nodes&quot;</span> source=<span style="color: #ff0000;">&quot;nodesAndStuff.xml&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:List</span> id=<span style="color: #ff0000;">&quot;lst&quot;</span></span>
<span style="color: #000000;">            labelField=<span style="color: #ff0000;">&quot;@label&quot;</span></span>
<span style="color: #000000;">            horizontalCenter=<span style="color: #ff0000;">&quot;0&quot;</span> verticalCenter=<span style="color: #ff0000;">&quot;0&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:dataProvider</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:XMLListCollection</span> id=<span style="color: #ff0000;">&quot;xmlListColl&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:dataProvider</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:List</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p class="alert">This entry is based on a beta version of the Flex 4 SDK and therefore is very likely to change as development of the Flex SDK continues. The API can (and will) change causing examples to possibly not compile in newer versions of the Flex 4 SDK.</p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Using an XML data provider with the Spark List control in Flex 4 on FlexExamples.com',url: 'http://blog.flexexamples.com/2009/11/04/using-an-xml-data-provider-with-the-spark-list-control-in-flex-4/',contentID: 'post-2163',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'children,dataProvider,Gumbo,IList,source',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/2009/11/04/using-an-xml-data-provider-with-the-spark-list-control-in-flex-4/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Using an Array as a data provider in a Flex Tree control</title>
		<link>http://blog.flexexamples.com/2007/12/03/using-an-array-as-a-data-provider-in-a-flex-tree-control/</link>
		<comments>http://blog.flexexamples.com/2007/12/03/using-an-array-as-a-data-provider-in-a-flex-tree-control/#comments</comments>
		<pubDate>Tue, 04 Dec 2007 07:36:41 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Tree]]></category>
		<category><![CDATA[children]]></category>
		<category><![CDATA[dataProvider]]></category>
		<category><![CDATA[hasChildren()]]></category>
		<category><![CDATA[labelFunction]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2007/12/03/using-an-array-as-a-data-provider-in-a-flex-tree-control/</guid>
		<description><![CDATA[<p>The following code shows you how you can use an Array as a data provider for a Tree control in Flex.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Tree_dataProvider_test/main.mxml">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2007/12/03/using-an-array-as-a-data-provider-in-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:Object):String { var suffix:String = ""; if (tree.dataDescriptor.hasChildren(item)) { [...]]]></description>
			<content:encoded><![CDATA[<p>The following code shows you how you can use an Array as a data provider for a Tree control in Flex.</p>
<p>Full code after the jump.</p>
<p><span id="more-349"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Tree_dataProvider_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/12/03/using-an-array-as-a-data-provider-in-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:Object):String {
                var suffix:String = "";
                if (tree.dataDescriptor.hasChildren(item)) {
                    suffix = " (" + item.children.length + ")";
                }
                return item.name.toUpperCase() + suffix;
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:Array id="arr"&gt;
        &lt;mx:Object name="One"&gt;
            &lt;mx:children&gt;
                &lt;mx:Array&gt;
                    &lt;mx:Object name="Two" /&gt;
                    &lt;mx:Object name="Three" /&gt;
                    &lt;mx:Object name="Four"&gt;
                        &lt;mx:children&gt;
                            &lt;mx:Array&gt;
                                &lt;mx:Object name="Five" /&gt;
                                &lt;mx:Object name="Six" /&gt;
                            &lt;/mx:Array&gt;
                        &lt;/mx:children&gt;
                    &lt;/mx:Object&gt;
                    &lt;mx:Object name="Seven"&gt;
                        &lt;mx:children&gt;
                            &lt;mx:Array&gt;
                                &lt;mx:Object name="Eight" /&gt;
                            &lt;/mx:Array&gt;
                        &lt;/mx:children&gt;
                    &lt;/mx:Object&gt;
                    &lt;mx:Object name="Nine" /&gt;
                &lt;/mx:Array&gt;
            &lt;/mx:children&gt;
        &lt;/mx:Object&gt;
    &lt;/mx:Array&gt;

    &lt;mx:Tree id="tree"
            dataProvider="{arr}"
            labelFunction="tree_labelFunc"
            width="200" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/Tree_dataProvider_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_dataProvider_test/bin/main.html" width="100%" height="300"></iframe></p>
<p class="new">And if you happen to be using <a href="http://opensource.adobe.com/wiki/display/flexsdk/Gumbo">Flex 4</a> (<a href="http://labs.adobe.com/technologies/flashbuilder4/">download</a>), the following example should work:</p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark"
        xmlns:mx="library://ns.adobe.com/flex/halo"&gt;

    &lt;fx:Script&gt;
        &lt;![CDATA[
            private function tree_labelFunc(item:Object):String {
                var suffix:String = "";
                if (tree.dataDescriptor.hasChildren(item)) {
                    suffix = " (" + item.children.length + ")";
                }
                return item.name.toUpperCase() + suffix;
            }
        ]]&gt;
    &lt;/fx:Script&gt;

    &lt;fx:Declarations&gt;
        &lt;fx:Array id="arr"&gt;
            &lt;fx:Object name="One"&gt;
                &lt;fx:children&gt;
                    &lt;fx:Array&gt;
                        &lt;fx:Object name="Two" /&gt;
                        &lt;fx:Object name="Three" /&gt;
                        &lt;fx:Object name="Four"&gt;
                            &lt;fx:children&gt;
                                &lt;fx:Array&gt;
                                    &lt;fx:Object name="Five" /&gt;
                                    &lt;fx:Object name="Six" /&gt;
                                &lt;/fx:Array&gt;
                            &lt;/fx:children&gt;
                        &lt;/fx:Object&gt;
                        &lt;fx:Object name="Seven"&gt;
                            &lt;fx:children&gt;
                                &lt;fx:Array&gt;
                                    &lt;fx:Object name="Eight" /&gt;
                                &lt;/fx:Array&gt;
                            &lt;/fx:children&gt;
                        &lt;/fx:Object&gt;
                        &lt;fx:Object name="Nine" /&gt;
                    &lt;/fx:Array&gt;
                &lt;/fx:children&gt;
            &lt;/fx:Object&gt;
        &lt;/fx:Array&gt;
    &lt;/fx:Declarations&gt;

    &lt;mx:Tree id="tree"
            dataProvider="{arr}"
            labelFunction="tree_labelFunc"
            width="200"
            horizontalCenter="0"
            verticalCenter="0" /&gt;

&lt;/s:Application&gt;
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Using an Array as a data provider in a Flex Tree control on FlexExamples.com',url: 'http://blog.flexexamples.com/2007/12/03/using-an-array-as-a-data-provider-in-a-flex-tree-control/',contentID: 'post-349',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'children,dataProvider,hasChildren(),labelFunction',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/12/03/using-an-array-as-a-data-provider-in-a-flex-tree-control/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

