0 Replies Latest reply on Nov 16, 2010 10:05 PM by Chillico

    Newbie question about navigation and custom components

    Chillico

      I need some advice about pathing (I think) of events called from within a nested custom component.  I am am trying to move panels into components but when I do so I loose the ability to change the selectedIndex of a parent viewstack.    I am current getting an error with my component file saying "Access of undefined property viewstack1".  I have included an example below.  I would be very greatful for any advice on the correct path.

       

       

      example.mxml (application main)

       

      <?xml version="1.0" encoding="utf-8"?>

      <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"

              xmlns:components="components.*"

              width="900" height="700"

              backgroundColor="#000066">

      <fx:Declarations>

           <!-- Place non-visual elements (e.g., services, value objects) here -->

      </fx:Declarations>

      <mx:ViewStack id="viewstack1" x="5" y="70" width="890" height="600" backgroundColor="#FFFFFF" cornerRadius="10">

       

           <s:NavigatorContent id="view1" label="View 1" width="100%" height="100%">

                <s:Label text="View 1" />

                <s:Panel x="50" y="50" width="250" height="400">

                     <s:Button label="Change to View 2" horizontalCenter="0" top="25" click="viewstack1.selectedIndex=1;"/>

                </s:Panel>

           </s:NavigatorContent>

       

           <s:NavigatorContent id="view2" label="View 2" width="100%" height="100%">

                <s:Label text="View 2" />

                <components:testComponent x="50" y="50" />

           </s:NavigatorContent>

       

      </mx:ViewStack>

       

      </s:WindowedApplication>

       

       

      testComponent.mxml

       

      <?xml version="1.0" encoding="utf-8"?>

      <s:Panel 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="250" height="400"

            title="Test Component">

       

      <fx:Declarations>

           <!-- Place non-visual elements (e.g., services, value objects) here -->

      </fx:Declarations>

       

           <s:Button label="Back to View 1" horizontalCenter="0" top="25" click="viewstack1.selectedIndex=0;"/>

       

      </s:Panel>

       

       

      I am also having the same issue when I try to change the state of a hosted component from a button in a nested component.  Thank you in advance for any help rendered.

       

      Scott