<?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; dataDescriptor</title>
	<atom:link href="http://blog.flexexamples.com/tag/datadescriptor/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>Opening branches by clicking rows in a Tree control in Flex</title>
		<link>http://blog.flexexamples.com/2008/04/05/opening-branches-by-clicking-rows-in-a-tree-control-in-flex/</link>
		<comments>http://blog.flexexamples.com/2008/04/05/opening-branches-by-clicking-rows-in-a-tree-control-in-flex/#comments</comments>
		<pubDate>Sat, 05 Apr 2008 15:59:18 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Tree]]></category>
		<category><![CDATA[dataDescriptor]]></category>
		<category><![CDATA[expandItem()]]></category>
		<category><![CDATA[getChildren()]]></category>
		<category><![CDATA[isBranch]]></category>
		<category><![CDATA[isItemOpen()]]></category>
		<category><![CDATA[itemClick]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/04/05/opening-branches-by-clicking-rows-in-a-tree-control-in-flex/</guid>
		<description><![CDATA[<p>The following example shows how you can expand/collapse branches in a Flex Tree control by clicking on the row instead of having to click on the disclosure/arrow icon.</p> <p></p> &#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62; &#60;!-- http://blog.flexexamples.com/2008/04/05/opening-branches-by-clicking-rows-in-a-tree-control-in-flex/ --&#62; &#60;mx:Application name=&#34;Tree_itemClick_test&#34; xmlns:mx=&#34;http://www.adobe.com/2006/mxml&#34; layout=&#34;vertical&#34; verticalAlign=&#34;middle&#34; backgroundColor=&#34;white&#34;&#62; &#160; &#60;mx:Script&#62; &#60;![CDATA[ import mx.collections.ICollectionView; import mx.events.ListEvent; &#160; private function tree_itemClick(evt:ListEvent):void { var item:Object [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can expand/collapse branches in a Flex Tree control by clicking on the row instead of having to click on the disclosure/arrow icon.</p>
<p><span id="more-588"></span></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/2008/04/05/opening-branches-by-clicking-rows-in-a-tree-control-in-flex/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Application</span> name=<span style="color: #ff0000;">&quot;Tree_itemClick_test&quot;</span></span>
<span style="color: #000000;">        xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span></span>
<span style="color: #000000;">        layout=<span style="color: #ff0000;">&quot;vertical&quot;</span></span>
<span style="color: #000000;">        verticalAlign=<span style="color: #ff0000;">&quot;middle&quot;</span></span>
<span style="color: #000000;">        backgroundColor=<span style="color: #ff0000;">&quot;white&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #339933;">&lt;mx:Script&gt;</span>
<span style="color: #339933;">        &lt;![CDATA[</span>
<span style="color: #339933;">            import mx.collections.ICollectionView;</span>
<span style="color: #339933;">            import mx.events.ListEvent;</span>
&nbsp;
<span style="color: #339933;">            private function tree_itemClick(evt:ListEvent):void {</span>
<span style="color: #339933;">                var item:Object = Tree(evt.currentTarget).selectedItem;</span>
<span style="color: #339933;">                if (tree.dataDescriptor.isBranch(item)) {</span>
<span style="color: #339933;">                    tree.expandItem(item, !tree.isItemOpen(item), true);</span>
<span style="color: #339933;">                }</span>
<span style="color: #339933;">            }</span>
&nbsp;
<span style="color: #339933;">            private function tree_labelFunc(item:XML):String {</span>
<span style="color: #339933;">                var children:ICollectionView;</span>
<span style="color: #339933;">                var suffix:String = &quot;&quot;;</span>
<span style="color: #339933;">                if (tree.dataDescriptor.isBranch(item)) {</span>
<span style="color: #339933;">                    children = tree.dataDescriptor.getChildren(item);</span>
<span style="color: #339933;">                    suffix = &quot; (&quot; + children.length + &quot;)&quot;;</span>
<span style="color: #339933;">                }</span>
<span style="color: #339933;">                return item[tree.labelField] + suffix;</span>
<span style="color: #339933;">            }</span>
<span style="color: #339933;">        ]]&gt;</span>
<span style="color: #339933;">    &lt;/mx:Script&gt;</span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:XML</span> id=<span style="color: #ff0000;">&quot;dp&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;">&lt;root<span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;">&lt;folder label=<span style="color: #ff0000;">&quot;One&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;">&lt;folder label=<span style="color: #ff0000;">&quot;One.A&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                    <span style="color: #000000;">&lt;item label=<span style="color: #ff0000;">&quot;One.A.1&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                    <span style="color: #000000;">&lt;item label=<span style="color: #ff0000;">&quot;One.A.2&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                    <span style="color: #000000;">&lt;item label=<span style="color: #ff0000;">&quot;One.A.3&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                    <span style="color: #000000;">&lt;item label=<span style="color: #ff0000;">&quot;One.A.4&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                    <span style="color: #000000;">&lt;item label=<span style="color: #ff0000;">&quot;One.A.5&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;">&lt;/folder<span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;">&lt;item label=<span style="color: #ff0000;">&quot;One.1&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;">&lt;item label=<span style="color: #ff0000;">&quot;One.2&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;">&lt;/folder<span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;">&lt;folder label=<span style="color: #ff0000;">&quot;Two&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;">&lt;item label=<span style="color: #ff0000;">&quot;Two.1&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;">&lt;folder label=<span style="color: #ff0000;">&quot;Two.A&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                    <span style="color: #000000;">&lt;item label=<span style="color: #ff0000;">&quot;Two.A.1&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                    <span style="color: #000000;">&lt;item label=<span style="color: #ff0000;">&quot;Two.A.2&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;">&lt;/folder<span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;">&lt;/folder<span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;">&lt;/root<span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:XML</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Tree</span> id=<span style="color: #ff0000;">&quot;tree&quot;</span></span>
<span style="color: #000000;">            dataProvider=<span style="color: #ff0000;">&quot;{dp}&quot;</span></span>
<span style="color: #000000;">            showRoot=<span style="color: #ff0000;">&quot;false&quot;</span></span>
<span style="color: #000000;">            labelField=<span style="color: #ff0000;">&quot;@label&quot;</span></span>
<span style="color: #000000;">            labelFunction=<span style="color: #ff0000;">&quot;tree_labelFunc&quot;</span></span>
<span style="color: #000000;">            width=<span style="color: #ff0000;">&quot;300&quot;</span></span>
<span style="color: #000000;">            rowCount=<span style="color: #ff0000;">&quot;6&quot;</span></span>
<span style="color: #000000;">            itemClick=<span style="color: #ff0000;">&quot;tree_itemClick(event);&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/Tree_expandItem_test_2/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_expandItem_test_2/bin/main.html" width="100%" height="200"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Opening branches by clicking rows in a Tree control in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/04/05/opening-branches-by-clicking-rows-in-a-tree-control-in-flex/',contentID: 'post-588',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'dataDescriptor,expandItem(),getChildren(),isBranch,isItemOpen(),itemClick',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/2008/04/05/opening-branches-by-clicking-rows-in-a-tree-control-in-flex/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
		<item>
		<title>Creating a simple image gallery with the Flex Tree control</title>
		<link>http://blog.flexexamples.com/2008/04/04/creating-a-simple-image-gallery-with-the-flex-tree-control/</link>
		<comments>http://blog.flexexamples.com/2008/04/04/creating-a-simple-image-gallery-with-the-flex-tree-control/#comments</comments>
		<pubDate>Sat, 05 Apr 2008 01:31:52 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[SWFLoader]]></category>
		<category><![CDATA[Tree]]></category>
		<category><![CDATA[dataDescriptor]]></category>
		<category><![CDATA[hasOwnProperty()]]></category>
		<category><![CDATA[isBranch]]></category>
		<category><![CDATA[itemRenderer]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/04/04/creating-a-simple-image-gallery-with-the-flex-tree-control/</guid>
		<description><![CDATA[<p>The following example shows how you can create a simple image gallery in Flex using a Tree control and a SWFLoader control.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Tree_gallery_test/bin/srcview/source/main.mxml.html">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2008/04/04/creating-a-simple-image-gallery-with-the-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[ import mx.events.ListEvent; private function tree_itemClick(evt:ListEvent):void { var t:Tree = evt.currentTarget [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can create a simple image gallery in Flex using a Tree control and a SWFLoader control.</p>
<p>Full code after the jump.</p>
<p><span id="more-587"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Tree_gallery_test/bin/srcview/source/main.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/04/04/creating-a-simple-image-gallery-with-the-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[
            import mx.events.ListEvent;

            private function tree_itemClick(evt:ListEvent):void {
                var t:Tree = evt.currentTarget as Tree;
                var dataObj:Object = evt.itemRenderer.data;
                if (dataObj.hasOwnProperty("@src")) {
                    swfLoader.source = dataObj.@src;
                } else if (t.dataDescriptor.isBranch(t.selectedItem)) {
                    swfLoader.source = null;
                    panel.status = "";
                }
            }

            private function tree_labelFunc(item:Object):String {
                var suffix:String = "";
                if (tree.dataDescriptor.isBranch(item)) {
                    suffix = " (" + item.children().length() + ")";
                }
                return item.@label + suffix;
            }

            private function swfLoader_complete(evt:Event):void {
                panel.status = (swfLoader.bytesTotal/1024).toFixed(2) + 'KB';
            }
        ]]&gt;
    &lt;/mx:Script&gt;

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

    &lt;mx:HDividedBox width="100%" height="100%"&gt;
        &lt;mx:Panel width="200" height="100%"&gt;
            &lt;mx:Tree id="tree"
                    dataProvider="{dp}"
                    labelFunction="tree_labelFunc"
                    showRoot="false"
                    width="100%"
                    height="100%"
                    itemClick="tree_itemClick(event);" /&gt;
        &lt;/mx:Panel&gt;
        &lt;mx:Panel id="panel"
                width="100%"
                height="100%"
                backgroundColor="white"&gt;
            &lt;mx:SWFLoader id="swfLoader"
                    scaleContent="true"
                    width="100%"
                    height="100%"
                    complete="swfLoader_complete(event);" /&gt;
            &lt;mx:ControlBar&gt;
                &lt;mx:LinkButton label="{swfLoader.source.toString()}" /&gt;
            &lt;/mx:ControlBar&gt;
        &lt;/mx:Panel&gt;
    &lt;/mx:HDividedBox&gt;

&lt;/mx:Application&gt;
</pre>
<p class="download">data/dp.xml</p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/04/04/creating-a-simple-image-gallery-with-the-flex-tree-control/ --&gt;
&lt;root&gt;
    &lt;gallery label="RIA"&gt;
        &lt;file label="ColdFusion" src="assets/cf_appicon.jpg" /&gt;
        &lt;file label="Dreamweaver" src="assets/dw_appicon.jpg" /&gt;
        &lt;file label="Flash" src="assets/fl_appicon.jpg" /&gt;
        &lt;file label="Flash Player" src="assets/fl_player_appicon.jpg" /&gt;
        &lt;file label="Flex" src="assets/fx_appicon.jpg" /&gt;
    &lt;/gallery&gt;
&lt;/root&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/Tree_gallery_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_gallery_test/bin/main.html" width="100%" height="500"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Creating a simple image gallery with the Flex Tree control on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/04/04/creating-a-simple-image-gallery-with-the-flex-tree-control/',contentID: 'post-587',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'dataDescriptor,hasOwnProperty(),isBranch,itemRenderer',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/2008/04/04/creating-a-simple-image-gallery-with-the-flex-tree-control/feed/</wfw:commentRss>
		<slash:comments>32</slash:comments>
		</item>
		<item>
		<title>Determining if a check box menu item is toggled in a Flex PopUpButton control&#8217;s pop up menu</title>
		<link>http://blog.flexexamples.com/2008/02/11/determining-if-a-check-box-menu-item-is-toggled-in-a-flex-popupbutton-controls-pop-up-menu/</link>
		<comments>http://blog.flexexamples.com/2008/02/11/determining-if-a-check-box-menu-item-is-toggled-in-a-flex-popupbutton-controls-pop-up-menu/#comments</comments>
		<pubDate>Tue, 12 Feb 2008 06:29:40 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Menu]]></category>
		<category><![CDATA[PopUpButton]]></category>
		<category><![CDATA[dataDescriptor]]></category>
		<category><![CDATA[getType()]]></category>
		<category><![CDATA[isToggled()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/02/11/determining-if-a-check-box-menu-item-is-toggled-in-a-flex-popupbutton-controls-pop-up-menu/</guid>
		<description><![CDATA[<p>The following example shows you how you can determine if a check box menu item in a Flex PopUpButton control was checked or not by using the change event on the pop up menu along with the dataDescriptor property and isToggled() method.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/PopUpButton_popUp_dataDescriptor_isToggled_test/main.mxml">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows you how you can determine if a check box menu item in a Flex PopUpButton control was checked or not by using the <code>change</code> event on the pop up menu along with the <code>dataDescriptor</code> property and <code>isToggled()</code> method.</p>
<p>Full code after the jump.</p>
<p><span id="more-509"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/PopUpButton_popUp_dataDescriptor_isToggled_test/main.mxml">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/02/11/determining-if-a-check-box-menu-item-is-toggled-in-a-flex-popupbutton-controls-pop-up-menu/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="top"
        backgroundColor="white"&gt;

    &lt;mx:Style&gt;
        PopUpButton {
            popUpStyleName: MyCustomPopUpStyleName;
        }

        .MyCustomPopUpStyleName {
            fontWeight: normal;
            textAlign: left;
        }

        .redModal {
            modalTransparencyColor: red;
            modalTransparency: 0.8;
        }

        .greenModal {
            modalTransparencyColor: haloGreen;
            modalTransparency: 0.8;
        }
    &lt;/mx:Style&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.events.MenuEvent;
            import mx.controls.Menu;
            import mx.controls.Alert;

            private var menu:Menu;
            private function init():void {
                menu = new Menu();
                menu.variableRowHeight = true;
                menu.dataProvider = arr;
                menu.addEventListener(MenuEvent.CHANGE, menu_change);
                popUpButton.popUp = menu;
            }

            private function menu_change(evt:MenuEvent):void {
                switch (menu.dataDescriptor.getType(evt.item)) {
                    case "check":
                        if (menu.dataDescriptor.isToggled(evt.item)) {
                            application.styleName = "greenModal";
                            Alert.show("\\"" + evt.item.label + "\\" was checked");
                        } else {
                            application.styleName = "redModal";
                            Alert.show("\\"" + evt.item.label + "\\" was not checked");
                        }
                        break;
                }
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:Array id="arr"&gt;
        &lt;mx:Object label="Option 1"
                type="check"
                toggled="true" /&gt;
        &lt;mx:Object label="Option 2"
                type="check"
                toggled="true" /&gt;
    &lt;/mx:Array&gt;

    &lt;mx:PopUpButton id="popUpButton"
            label="Click to open..."
            openAlways="true"
            initialize="init();" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/PopUpButton_popUp_dataDescriptor_isToggled_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/PopUpButton_popUp_dataDescriptor_isToggled_test/bin/main.html" width="100%" height="200"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Determining if a check box menu item is toggled in a Flex PopUpButton control\&#039;s pop up menu on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/02/11/determining-if-a-check-box-menu-item-is-toggled-in-a-flex-popupbutton-controls-pop-up-menu/',contentID: 'post-509',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'dataDescriptor,getType(),isToggled()',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/2008/02/11/determining-if-a-check-box-menu-item-is-toggled-in-a-flex-popupbutton-controls-pop-up-menu/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Preventing branches from being selected in a Flex Tree control</title>
		<link>http://blog.flexexamples.com/2008/01/16/preventing-branches-from-being-selected-in-a-flex-tree-control/</link>
		<comments>http://blog.flexexamples.com/2008/01/16/preventing-branches-from-being-selected-in-a-flex-tree-control/#comments</comments>
		<pubDate>Thu, 17 Jan 2008 04:48:02 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Tree]]></category>
		<category><![CDATA[dataDescriptor]]></category>
		<category><![CDATA[isBranch]]></category>
		<category><![CDATA[itemClick]]></category>
		<category><![CDATA[selectedItem]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/01/16/preventing-branches-from-being-selected-in-a-flex-tree-control/</guid>
		<description><![CDATA[<p>The following example shows you how you can prevent users from selecting the branch (folder) items in a Tree control in Flex by listening for the itemClick event and using the Tree class&#8217;s dataDescriptor.isBranch() method to determine whether the currently selected item is a branch, and if so, deselect the item.</p> <p>Full code after the [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows you how you can prevent users from selecting the branch (folder) items in a Tree control in Flex by listening for the <code>itemClick</code> event and using the Tree class&#8217;s <code>dataDescriptor.isBranch()</code> method to determine whether the currently selected item is a branch, and if so, deselect the item.</p>
<p>Full code after the jump.</p>
<p><span id="more-460"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Tree_selectedItem_test/main.mxml">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/01/16/preventing-branches-from-being-selected-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[
            import mx.events.ListEvent;

            private function tree_itemClick(evt:ListEvent):void {
                var item:Object = evt.currentTarget.selectedItem
                if (tree.dataDescriptor.isBranch(item)) {
                    tree.selectedItem = null;
                }
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:XML id="dp"&gt;
        &lt;root&gt;
            &lt;node label="Parent 1"&gt;
                &lt;node label="Child 1" /&gt;
                &lt;node label="Child 2"&gt;
                    &lt;node label="Grandchild 1" /&gt;
                    &lt;node label="Grandchild 2" /&gt;
                &lt;/node&gt;
                &lt;node label="Child 3" /&gt;
                &lt;node label="Child 4" /&gt;
            &lt;/node&gt;
        &lt;/root&gt;
    &lt;/mx:XML&gt;

    &lt;mx:Tree id="tree"
            dataProvider="{dp}"
            showRoot="false"
            labelField="@label"
            width="200"
            itemClick="tree_itemClick(event);" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/Tree_selectedItem_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_selectedItem_test/bin/main.html" width="100%" height="250"></iframe></p>
<p class="construction">For more information on disabling list selection in the List/Tree/ComboBox controls, see Alex Harui&#8217;s excellent blog entry, <a href="http://blogs.adobe.com/aharui/2007/06/disabling_list_selection.html">&#8220;Disabling List Selection&#8221;</a>.</p>
<p class="new">For another example, see <a href="http://blog.flexexamples.com/2008/01/16/preventing-specific-items-from-being-selected-in-a-flex-tree-control/">&#8220;Preventing specific items from being selected in a Flex Tree control&#8221;</a>.</p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Preventing branches from being selected in a Flex Tree control on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/01/16/preventing-branches-from-being-selected-in-a-flex-tree-control/',contentID: 'post-460',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'dataDescriptor,isBranch,itemClick,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/2008/01/16/preventing-branches-from-being-selected-in-a-flex-tree-control/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Using the isBranch() method to determine if a Tree item is a branch or leaf</title>
		<link>http://blog.flexexamples.com/2007/11/30/using-the-isbranch-method-to-determine-if-a-tree-item-is-a-branch-or-leaf/</link>
		<comments>http://blog.flexexamples.com/2007/11/30/using-the-isbranch-method-to-determine-if-a-tree-item-is-a-branch-or-leaf/#comments</comments>
		<pubDate>Sat, 01 Dec 2007 06:51:48 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Tree]]></category>
		<category><![CDATA[dataDescriptor]]></category>
		<category><![CDATA[isBranch]]></category>
		<category><![CDATA[labelFunction]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2007/11/30/using-the-isbranch-method-to-determine-if-a-tree-item-is-a-branch-or-leaf/</guid>
		<description><![CDATA[<p>The following example shows how you can use the isBranch() method to determine if a specific node in a Tree control is a branch (folder) or leaf (item).</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Tree_dataDescriptor_isBranch_test/bin/srcview/source/main.mxml.html">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2007/11/30/using-the-isbranch-method-to-determine-if-a-tree-item-is-a-branch-or-leaf/ --&#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[ import mx.events.ListEvent; private function [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can use the <code>isBranch()</code> method to determine if a specific node in a Tree control is a branch (folder) or leaf (item).</p>
<p>Full code after the jump.</p>
<p><span id="more-345"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Tree_dataDescriptor_isBranch_test/bin/srcview/source/main.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2007/11/30/using-the-isbranch-method-to-determine-if-a-tree-item-is-a-branch-or-leaf/ --&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[
            import mx.events.ListEvent;

            private function tree_itemClick(evt:ListEvent):void {
                var itemIsBranch:Boolean = tree.dataDescriptor.isBranch(tree.selectedItem);
                lbl.text = itemIsBranch.toString();
            }

            private function tree_labelFunc(item:XML):String {
                var returnStr:String = item.@label;
                var itemIsBranch:Boolean = tree.dataDescriptor.isBranch(item);
                if (itemIsBranch) {
                    returnStr += " (BRANCH)";
                }
                return returnStr;
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:XML id="xmlDP"&gt;
        &lt;node&gt;
            &lt;node label="1.a" /&gt;
            &lt;node label="1.b" /&gt;
            &lt;node label="1.c"&gt;
                &lt;node label="1.c.i" /&gt;
                &lt;node label="1.c.ii" /&gt;
                &lt;node label="1.c.iii" /&gt;
                &lt;node label="1.c.iv" /&gt;
                &lt;node label="1.c.v" /&gt;
            &lt;/node&gt;
            &lt;node label="1.d" /&gt;
            &lt;node label="1.e"&gt;
                &lt;node label="1.e.i" /&gt;
                &lt;node label="1.e.ii" /&gt;
                &lt;node label="1.e.iii"&gt;
                    &lt;node label="1.e.iii.A" /&gt;
                &lt;/node&gt;
                &lt;node label="1.e.iv" /&gt;
            &lt;/node&gt;
            &lt;node label="1.f" /&gt;
        &lt;/node&gt;
    &lt;/mx:XML&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Form styleName="plain"&gt;
            &lt;mx:FormItem label="isBranch():"&gt;
                &lt;mx:Label id="lbl" fontWeight="bold" /&gt;
            &lt;/mx:FormItem&gt;
        &lt;/mx:Form&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:Tree id="tree"
            dataProvider="{xmlDP}"
            labelFunction="tree_labelFunc"
            showRoot="false"
            width="50%"
            rowCount="6"
            itemClick="tree_itemClick(event);" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/Tree_dataDescriptor_isBranch_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_dataDescriptor_isBranch_test/bin/main.html" width="100%" height="250"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Using the isBranch() method to determine if a Tree item is a branch or leaf on FlexExamples.com',url: 'http://blog.flexexamples.com/2007/11/30/using-the-isbranch-method-to-determine-if-a-tree-item-is-a-branch-or-leaf/',contentID: 'post-345',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'dataDescriptor,isBranch,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/11/30/using-the-isbranch-method-to-determine-if-a-tree-item-is-a-branch-or-leaf/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

