<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Dynamically adding new children to a Flex Accordion container</title>
	<atom:link href="http://blog.flexexamples.com/2007/09/18/dynamically-adding-new-children-to-a-flex-accordion-container/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexexamples.com/2007/09/18/dynamically-adding-new-children-to-a-flex-accordion-container/</link>
	<description>Just a bunch of Adobe Flex Examples</description>
	<lastBuildDate>Sun, 12 Feb 2012 19:26:49 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Gajendra S V</title>
		<link>http://blog.flexexamples.com/2007/09/18/dynamically-adding-new-children-to-a-flex-accordion-container/comment-page-1/#comment-8578</link>
		<dc:creator>Gajendra S V</dc:creator>
		<pubDate>Tue, 30 Nov 2010 05:14:28 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/09/18/dynamically-adding-new-children-to-a-flex-accordion-container/#comment-8578</guid>
		<description>I want add button to dynamically added accordion please inform me how to add?</description>
		<content:encoded><![CDATA[<p>I want add button to dynamically added accordion please inform me how to add?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Igor</title>
		<link>http://blog.flexexamples.com/2007/09/18/dynamically-adding-new-children-to-a-flex-accordion-container/comment-page-1/#comment-6711</link>
		<dc:creator>Igor</dc:creator>
		<pubDate>Fri, 01 Jan 2010 15:01:39 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/09/18/dynamically-adding-new-children-to-a-flex-accordion-container/#comment-6711</guid>
		<description>Has anyone noticed that when clicking on the header and animation run, right border of Accordion flickers, I came to the conclusion that this is due to the fact that in AS code we use the properties percentHeigth and percentWidth, if you add child in MXML, then this is no flicker.</description>
		<content:encoded><![CDATA[<p>Has anyone noticed that when clicking on the header and animation run, right border of Accordion flickers, I came to the conclusion that this is due to the fact that in AS code we use the properties percentHeigth and percentWidth, if you add child in MXML, then this is no flicker.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter deHaan</title>
		<link>http://blog.flexexamples.com/2007/09/18/dynamically-adding-new-children-to-a-flex-accordion-container/comment-page-1/#comment-6417</link>
		<dc:creator>Peter deHaan</dc:creator>
		<pubDate>Fri, 20 Nov 2009 16:08:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/09/18/dynamically-adding-new-children-to-a-flex-accordion-container/#comment-6417</guid>
		<description>@Nicolas,

Kind of makes sense. If you have two children and then you call &lt;code&gt;accordion.removeChildAt(0);&lt;/code&gt;, then you&#039;re left with one child, which moves to the 0 position. So when you call &lt;code&gt;accordion.removeChildAt(1);&lt;/code&gt; you&#039;d get an error since the child formerly at 1 has moved to 0. You could either go in reverse like your example, or you could probably just do a loop and always remove the child at the 0 position. Or, you may be able to just set the Accordion container&#039;s data provider to an empty array and remove all the children at once.

Peter</description>
		<content:encoded><![CDATA[<p>@Nicolas,</p>
<p>Kind of makes sense. If you have two children and then you call <code>accordion.removeChildAt(0);</code>, then you&#8217;re left with one child, which moves to the 0 position. So when you call <code>accordion.removeChildAt(1);</code> you&#8217;d get an error since the child formerly at 1 has moved to 0. You could either go in reverse like your example, or you could probably just do a loop and always remove the child at the 0 position. Or, you may be able to just set the Accordion container&#8217;s data provider to an empty array and remove all the children at once.</p>
<p>Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nicolas</title>
		<link>http://blog.flexexamples.com/2007/09/18/dynamically-adding-new-children-to-a-flex-accordion-container/comment-page-1/#comment-6416</link>
		<dc:creator>Nicolas</dc:creator>
		<pubDate>Fri, 20 Nov 2009 12:59:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/09/18/dynamically-adding-new-children-to-a-flex-accordion-container/#comment-6416</guid>
		<description>Interesting. This only works if you countdown like removing items off a stack otherwise it causes an error. I didn&#039;t notice it until I had more than two items.
It makes sense now. As the number of children decreases the indexes change.
&lt;pre lang=&quot;actionscript3&quot;&gt;
//Removes all previous children from accordion
var numChildren:Number = accordion.numChildren
for(var i:Number=numChildren - 1; i &gt; -1; i--){
	accordion.removeChildAt(i);
}
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Interesting. This only works if you countdown like removing items off a stack otherwise it causes an error. I didn&#8217;t notice it until I had more than two items.<br />
It makes sense now. As the number of children decreases the indexes change.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #009900; font-style: italic;">//Removes all previous children from accordion</span>
<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">numChildren</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = accordion<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">numChildren</span>
<span style="color: #0033ff; font-weight: bold;">for</span><span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=<span style="color: #004993;">numChildren</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span> i <span style="color: #000066; font-weight: bold;">&gt;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">--</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
	accordion<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">removeChildAt</span><span style="color: #000000;">&#40;</span>i<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

]]></content:encoded>
	</item>
	<item>
		<title>By: Nicolas</title>
		<link>http://blog.flexexamples.com/2007/09/18/dynamically-adding-new-children-to-a-flex-accordion-container/comment-page-1/#comment-6394</link>
		<dc:creator>Nicolas</dc:creator>
		<pubDate>Thu, 19 Nov 2009 01:21:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/09/18/dynamically-adding-new-children-to-a-flex-accordion-container/#comment-6394</guid>
		<description>Solved!
&lt;pre lang=&quot;actionscript3&quot;&gt;
//Removes all previous children from accordion
var numChildren:Number = accordion.numChildren
for(var i:Number=0; i&lt;numChildren; i++){
		accordion.removeChildAt(i);
}
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Solved!</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #009900; font-style: italic;">//Removes all previous children from accordion</span>
<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">numChildren</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = accordion<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">numChildren</span>
<span style="color: #0033ff; font-weight: bold;">for</span><span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=<span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">&lt;</span>numChildren<span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
		accordion<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">removeChildAt</span><span style="color: #000000;">&#40;</span>i<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

]]></content:encoded>
	</item>
	<item>
		<title>By: Nicolas</title>
		<link>http://blog.flexexamples.com/2007/09/18/dynamically-adding-new-children-to-a-flex-accordion-container/comment-page-1/#comment-6393</link>
		<dc:creator>Nicolas</dc:creator>
		<pubDate>Thu, 19 Nov 2009 00:42:28 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/09/18/dynamically-adding-new-children-to-a-flex-accordion-container/#comment-6393</guid>
		<description>Navigating away to another state does not destroy the Accordion. When I come back again it is appending new children instead of starting from an empty accordion. Bizar? I was always under the impression that leaving a state removes that screen.
(maybe that was what was meant by Garbage collection)
Is there a way to rest the accordion so that it is empty?</description>
		<content:encoded><![CDATA[<p>Navigating away to another state does not destroy the Accordion. When I come back again it is appending new children instead of starting from an empty accordion. Bizar? I was always under the impression that leaving a state removes that screen.<br />
(maybe that was what was meant by Garbage collection)<br />
Is there a way to rest the accordion so that it is empty?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://blog.flexexamples.com/2007/09/18/dynamically-adding-new-children-to-a-flex-accordion-container/comment-page-1/#comment-4288</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Thu, 02 Jul 2009 14:11:46 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/09/18/dynamically-adding-new-children-to-a-flex-accordion-container/#comment-4288</guid>
		<description>is there a way to assign a unique &quot;id&quot; to each of the new children? And if this is possible, how would you reference those children later in the program with their unique ids?</description>
		<content:encoded><![CDATA[<p>is there a way to assign a unique &#8220;id&#8221; to each of the new children? And if this is possible, how would you reference those children later in the program with their unique ids?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jose</title>
		<link>http://blog.flexexamples.com/2007/09/18/dynamically-adding-new-children-to-a-flex-accordion-container/comment-page-1/#comment-1154</link>
		<dc:creator>Jose</dc:creator>
		<pubDate>Sun, 03 May 2009 23:00:11 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/09/18/dynamically-adding-new-children-to-a-flex-accordion-container/#comment-1154</guid>
		<description>Hi,

I need to add to a child from other children already created.

Example:

acGrupos.selectedChild.addChild(cmb1);

The idea is that this new child is within the selected.

Thanks</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I need to add to a child from other children already created.</p>
<p>Example:</p>
<p>acGrupos.selectedChild.addChild(cmb1);</p>
<p>The idea is that this new child is within the selected.</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jm</title>
		<link>http://blog.flexexamples.com/2007/09/18/dynamically-adding-new-children-to-a-flex-accordion-container/comment-page-1/#comment-1157</link>
		<dc:creator>jm</dc:creator>
		<pubDate>Fri, 06 Feb 2009 16:09:16 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/09/18/dynamically-adding-new-children-to-a-flex-accordion-container/#comment-1157</guid>
		<description>Hi

I have an application with a viewStack to separate my screens.
Everything works fine in the first screen, but in the second one, i
cannot call an ActionScript function in the show event of a VBox
container

I am assuming that when the second view is activated the show event of
the inner elements is called, but apparently i am mistaken. The
creationComplete event is valid for the first screen because it is
called when the application starts, but not for the second screen
elements because they are already created

Please help</description>
		<content:encoded><![CDATA[<p>Hi</p>
<p>I have an application with a viewStack to separate my screens.<br />
Everything works fine in the first screen, but in the second one, i<br />
cannot call an ActionScript function in the show event of a VBox<br />
container</p>
<p>I am assuming that when the second view is activated the show event of<br />
the inner elements is called, but apparently i am mistaken. The<br />
creationComplete event is valid for the first screen because it is<br />
called when the application starts, but not for the second screen<br />
elements because they are already created</p>
<p>Please help</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peterd</title>
		<link>http://blog.flexexamples.com/2007/09/18/dynamically-adding-new-children-to-a-flex-accordion-container/comment-page-1/#comment-1156</link>
		<dc:creator>peterd</dc:creator>
		<pubDate>Fri, 03 Oct 2008 06:25:50 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/09/18/dynamically-adding-new-children-to-a-flex-accordion-container/#comment-1156</guid>
		<description>Kirk,

The same general code should work for TabNavigator:
&lt;pre class=&quot;code&quot;&gt;
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;mx:Application name=&quot;TabNavigator_addChild_test&quot;
        xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
        layout=&quot;vertical&quot;
        verticalAlign=&quot;middle&quot;
        backgroundColor=&quot;white&quot;&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.containers.HBox;

            private function addChildButton_click(evt:MouseEvent):void {
                var box:HBox = new HBox();
                box.label = &quot;Child &quot; + tabNavigator.numChildren;
                box.percentWidth = 100;
                box.percentHeight = 100;
                box.setStyle(&quot;backgroundColor&quot;, int(Math.random() * 0xFFFFFF));
                tabNavigator.addChild(box);
            }

            private function removeChildButton_click(evt:MouseEvent):void {
                if (tabNavigator.selectedChild != null) {
                    tabNavigator.removeChild(tabNavigator.selectedChild);
                }
            }

            private function removeAllChildrenButton_click(evt:MouseEvent):void {
                tabNavigator.removeAllChildren();
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:ApplicationControlBar dock=&quot;true&quot;&gt;
        &lt;mx:Button id=&quot;addChildButton&quot;
                label=&quot;Add child&quot;
                click=&quot;addChildButton_click(event);&quot; /&gt;
        &lt;mx:Button id=&quot;removeChildButton&quot;
                label=&quot;Remove child&quot;
                click=&quot;removeChildButton_click(event);&quot; /&gt;
        &lt;mx:Button id=&quot;removeAllChildrenButton&quot;
                label=&quot;Remove all children&quot;
                click=&quot;removeAllChildrenButton_click(event);&quot; /&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:TabNavigator id=&quot;tabNavigator&quot;
            width=&quot;100%&quot;
            height=&quot;100%&quot; /&gt;

&lt;/mx:Application&gt;
&lt;/pre&gt;

Peter</description>
		<content:encoded><![CDATA[<p>Kirk,</p>
<p>The same general code should work for TabNavigator:</p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;mx:Application name="TabNavigator_addChild_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.containers.HBox;

            private function addChildButton_click(evt:MouseEvent):void {
                var box:HBox = new HBox();
                box.label = "Child " + tabNavigator.numChildren;
                box.percentWidth = 100;
                box.percentHeight = 100;
                box.setStyle("backgroundColor", int(Math.random() * 0xFFFFFF));
                tabNavigator.addChild(box);
            }

            private function removeChildButton_click(evt:MouseEvent):void {
                if (tabNavigator.selectedChild != null) {
                    tabNavigator.removeChild(tabNavigator.selectedChild);
                }
            }

            private function removeAllChildrenButton_click(evt:MouseEvent):void {
                tabNavigator.removeAllChildren();
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Button id="addChildButton"
                label="Add child"
                click="addChildButton_click(event);" /&gt;
        &lt;mx:Button id="removeChildButton"
                label="Remove child"
                click="removeChildButton_click(event);" /&gt;
        &lt;mx:Button id="removeAllChildrenButton"
                label="Remove all children"
                click="removeAllChildrenButton_click(event);" /&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:TabNavigator id="tabNavigator"
            width="100%"
            height="100%" /&gt;

&lt;/mx:Application&gt;
</pre>
<p>Peter</p>
]]></content:encoded>
	</item>
</channel>
</rss>

