<?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; numChildren</title>
	<atom:link href="http://blog.flexexamples.com/tag/numchildren/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>Setting the label placement on a TabBar control in Flex</title>
		<link>http://blog.flexexamples.com/2008/10/06/setting-the-label-placement-on-a-tabbar-control-in-flex/</link>
		<comments>http://blog.flexexamples.com/2008/10/06/setting-the-label-placement-on-a-tabbar-control-in-flex/#comments</comments>
		<pubDate>Tue, 07 Oct 2008 06:43:27 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[TabBar]]></category>
		<category><![CDATA[getChildAt()]]></category>
		<category><![CDATA[labelPlacement]]></category>
		<category><![CDATA[numChildren]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/10/06/setting-the-label-placement-on-a-tabbar-control-in-flex/</guid>
		<description><![CDATA[<p>In a previous example, <a href="http://blog.flexexamples.com/2007/11/19/styling-individual-tabs-in-a-tabbar-control/">&#8220;Styling individual tabs in a TabBar control&#8221;</a>, we saw how you could style individual tabs in a Flex TabBar control by calling the getChildAt() method on the tab bar, and then calling setStyle() on the returned Tab reference.</p> <p>The following example shows how you can loop over the tabs in [...]]]></description>
			<content:encoded><![CDATA[<p>In a previous example, <a href="http://blog.flexexamples.com/2007/11/19/styling-individual-tabs-in-a-tabbar-control/">&#8220;Styling individual tabs in a TabBar control&#8221;</a>, we saw how you could style individual tabs in a Flex TabBar control by calling the <code>getChildAt()</code> method on the tab bar, and then calling <code>setStyle()</code> on the returned Tab reference.</p>
<p>The following example shows how you can loop over the tabs in a Flex TabBar control and set each tab&#8217;s <code>labelPlacement</code> property.</p>
<p>Full code after the jump.</p>
<p><span id="more-820"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/TabBar_getChildAt_labelPlacement_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/10/06/setting-the-label-placement-on-a-tabbar-control-in-flex/ --&gt;
&lt;mx:Application name="TabBar_getChildAt_labelPlacement_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.controls.tabBarClasses.Tab;

            private function init():void {
                var tab:Tab;
                var idx:uint;
                var len:uint = tabBar.numChildren;
                for (idx=0; idx&lt;len; idx++) {
                    tab = tabBar.getChildAt(idx) as Tab;
                    tab.labelPlacement = tab.label;
                }
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:Array id="arr"&gt;
        &lt;mx:Object label="left"
                icon="@Embed('assets/arrow_left.png')" /&gt;
        &lt;mx:Object label="right"
                icon="@Embed('assets/arrow_right.png')" /&gt;
        &lt;mx:Object label="top"
                icon="@Embed('assets/arrow_up.png')" /&gt;
        &lt;mx:Object label="bottom"
                icon="@Embed('assets/arrow_down.png')" /&gt;
    &lt;/mx:Array&gt;

    &lt;mx:TabBar id="tabBar"
            dataProvider="{arr}"
            tabWidth="150"
            tabHeight="60"
            creationComplete="init();" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/TabBar_getChildAt_labelPlacement_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/TabBar_getChildAt_labelPlacement_test/bin/main.html" width="100%" height="150"></iframe></p>
<p>Due to popular demand, here is the &#8220;same&#8221; example in a more ActionScript friendly format:</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/TabBar_getChildAt_labelPlacement_test/bin/srcview/source/main2.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/10/06/setting-the-label-placement-on-a-tabbar-control-in-flex/ --&gt;
&lt;mx:Application name="TabBar_getChildAt_labelPlacement_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"
        initialize="init();"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.controls.ButtonLabelPlacement;
            import mx.controls.TabBar;
            import mx.controls.tabBarClasses.Tab;

            [Embed("assets/arrow_left.png")]
            private const ARROW_LEFT_ICON:Class;

            [Embed("assets/arrow_right.png")]
            private const ARROW_RIGHT_ICON:Class;

            [Embed("assets/arrow_up.png")]
            private const ARROW_TOP_ICON:Class;

            [Embed("assets/arrow_down.png")]
            private const ARROW_BOTTOM_ICON:Class;

            private var arr:Array;
            private var tabBar:TabBar;

            private function init():void {
                arr = [];
                arr.push({label:ButtonLabelPlacement.LEFT,
                            icon:ARROW_LEFT_ICON});
                arr.push({label:ButtonLabelPlacement.RIGHT,
                            icon:ARROW_RIGHT_ICON});
                arr.push({label:ButtonLabelPlacement.TOP,
                            icon:ARROW_TOP_ICON});
                arr.push({label:ButtonLabelPlacement.BOTTOM,
                            icon:ARROW_BOTTOM_ICON});

                tabBar = new TabBar();
                tabBar.dataProvider = arr;
                tabBar.setStyle("tabWidth", 150);
                tabBar.setStyle("tabHeight", 60);
                addChild(tabBar);

                var tab:Tab;
                var idx:uint;
                var len:uint = tabBar.numChildren;
                for (idx=0; idx&lt;len; idx++) {
                    tab = tabBar.getChildAt(idx) as Tab;
                    tab.labelPlacement = tab.label;
                }
            }
        ]]&gt;
    &lt;/mx:Script&gt;

&lt;/mx:Application&gt;
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Setting the label placement on a TabBar control in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/10/06/setting-the-label-placement-on-a-tabbar-control-in-flex/',contentID: 'post-820',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'getChildAt(),labelPlacement,numChildren',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/10/06/setting-the-label-placement-on-a-tabbar-control-in-flex/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

