title: Remove child content from ViewStack in Flex 4
body: <p>In my example below, when I click "Add Content", new stack content is loaded into the ViewStack as expected. But when I then click "Close Content", I'm expecting it to close the newly created content inside the ViewStack and switch to the "defaultContent" content.</p>
  
  <p>Can anyone tell me where I'm going wrong please? Thanks in advance.</p>
  
  <pre><code>// TestProject.mxml (application)
  &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                         xmlns:s="library://ns.adobe.com/flex/spark" 
                         xmlns:mx="library://ns.adobe.com/flex/mx"&gt;
      &lt;s:layout&gt;
          &lt;s:VerticalLayout/&gt;
      &lt;/s:layout&gt;
      &lt;fx:Script&gt;
          &lt;![CDATA[
              import com.NewContent;
  
              private function addContent():void
              {
                  var content:NewContent = new NewContent();
                  var navContent:NavigatorContent = new NavigatorContent();
                  navContent.id = 'newContent';
                  navContent.label = 'newContent';
                  navContent.width = Number('100%');
                  navContent.height = Number('100%');
                  navContent.addElement(content);
  
                  viewStack.addElement(navContent);
                  viewStack.selectedChild = navContent;
              }
          ]]&gt;
      &lt;/fx:Script&gt;
      &lt;mx:ViewStack id="viewStack" width="100%" height="100%"&gt;
          &lt;s:NavigatorContent id="defaultContent"
                              label="defaultContent"&gt;
              &lt;s:Button click="addContent()" label="Add Content"/&gt;
          &lt;/s:NavigatorContent&gt;
      &lt;/mx:ViewStack&gt;
  &lt;/s:WindowedApplication&gt;
  
  // NewContent.mxml (component)
  &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" 
           xmlns:s="library://ns.adobe.com/flex/spark" 
           xmlns:mx="library://ns.adobe.com/flex/mx"
           width="100%" height="100%"&gt;
      &lt;fx:Script&gt;
          &lt;![CDATA[
              import mx.core.FlexGlobals;
              private function closeContent():void
              {
                  FlexGlobals.topLevelApplication.viewStack.removeChild('newContent');
                  FlexGlobals.topLevelApplication.viewStack.selectedChild = 'defaultContent';
              }
          ]]&gt;
      &lt;/fx:Script&gt;
      &lt;s:Button click="closeContent()" label="Close Content"/&gt;
  &lt;/s:Group&gt;
  </code></pre>