10 Replies Latest reply on Jul 15, 2009 8:17 AM by Deeps45

    DisplayObject must be a child of the caller.

    Deeps45

      I am trying to remove the existing childs  (combobox and pods are the content in the page) using

      viewStack.selectedChild.removeAllChildren();

       

       

       

      in a tab click from the Viewstacks canvas.

      then I am trying to add new child.

       

      it gives this error.

       

      The supplied DisplayObject must be a child of the caller.
      at flash.display::DisplayObjectContainer/getChildIndex()
      at mx.core::Container/setChildIndex()[C:\autobuild\3.2.0\frameworks\projects\framework\src\m x\core\Container.as:2449]

       

      Please help me to fix this

       

       

        • 1. Re: DisplayObject must be a child of the caller.
          Flex harUI Adobe Employee

          Show the full stack trace and the code you are using to add the child

           

          Alex Harui

          Flex SDK Developer

          Adobe Systems Inc.

          Blog: http://blogs.adobe.com/aharui

          • 2. Re: DisplayObject must be a child of the caller.
            Deeps45 Level 1

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

            private function onApplicationComplete():

            void

            {

             

             

            var arrView:Array =new

            Array();

            arrView=viewStack.getChildren();

            viewLength=arrView.length;

             

             

             

             

             

             

            // Load pods.xml, which contains the pod layout.

             

             

            var httpService:HTTPService = new

            HTTPService();

            httpService.url =

             

            "data/pods.xml"

            ;

            httpService.resultFormat =

             

            "e4x"

            ;

            httpService.addEventListener(FaultEvent.FAULT, onFaultHttpService);

            httpService.addEventListener(ResultEvent.RESULT, onResultHttpService);

            httpService.send();

            }

             

             

             

            private function onFaultHttpService(e:FaultEvent):

            void

            {

            Alert.show(

             

            "Unable to load data/pods.xml."

            );

            }

             

             

            public var viewXMLList:XMLList =new

            XMLList();

             

             

            private function onResultHttpService(e:ResultEvent):

            void

            {

            viewXMLList = e.result.view;

             

             

            var podcontentbase:PodContentBase=new

            PodContentBase;

             

             

            var containerWindowManagerHash:Object = new

            Object();

             

             

            var

            len:Number = viewXMLList.length();

             

             

             

            if

            (podLayoutManagers.length!=0)

            podLayoutManagers.splice(0,podLayoutManagers.length);

             

             

             

            for (var i:Number = 0; i < len; i++)

            // Loop through the view nodes.

            {

             

             

            // Create a canvas for each view node.

             

             

            var canvas:Canvas = new

            Canvas();

             

             

            // PodLayoutManager handles resize and should prevent the need for

             

             

            // scroll bars so turn them off so they aren't visible during resizes.

            canvas.horizontalScrollPolicy =

             

            "off"

            ;

            canvas.verticalScrollPolicy =

             

            "off"

            ;

            canvas.label = viewXMLList[i].@label;

            canvas.percentWidth = 100;

            canvas.percentHeight = 100;

            viewStack.addChild(canvas);

             

            traceDL(viewStack);

             

             

             

            // Create a manager for each view.

             

             

            var manager:PodLayoutManager = new

            PodLayoutManager();

            manager.container = canvas;

            manager.id = viewXMLList[i].@id;

            manager.addEventListener(LayoutChangeEvent.UPDATE, StateManager.setPodLayout);

             

             

            // Store the pod xml data. Used when view is first made visible.

            podDataDictionary[manager] = viewXMLList[i].pod;

             

             

            //podcontentbase.podDataDictionarycopy[manager] = viewXMLList[i].pod;

             

            podLayoutManagers.push(manager);

            }

             

            onchange();

            }

             

             

            private function onchange():

            void

            {

            tabBar.dataProvider=viewStack;

             

             

            var

            index:Number = StateManager.getViewIndex();

             

             

            // Make sure the index is not out of range.

             

             

            // This can happen if a tab view was saved but then tabs were subsequently removed from the XML.

            index = Math.min(tabBar.numChildren - 1, index);

            onItemClickTabBar(

             

            new ItemClickEvent(ItemClickEvent.ITEM_CLICK, false, false, null

            , index));

            tabBar.selectedIndex = index;

            }

             

             

            private var

            indextab:Number;

             

             

             

            private function onItemClickTabBar(e:ItemClickEvent):

            void

            {

            indextab = e.index;

            StateManager.setViewIndex(indextab);

             

            // Save the view index.

            viewStack.selectedIndex = indextab;

             

             

            if( this

            .contains( viewStack.selectedChild) )

            viewStack.selectedChild.removeAllChildren();

            traceDL(

             

            this

            );

            • 3. Re: DisplayObject must be a child of the caller.
              Flex harUI Adobe Employee

              I didn't see the full stacktrace.  Usually that error shows up in a dialog with many more lines in it

               

              Alex Harui

              Flex SDK Developer

              Adobe Systems Inc.

              Blog: http://blogs.adobe.com/aharui

              • 4. Re: DisplayObject must be a child of the caller.
                Deeps45 Level 1

                This is the exact error im getting

                 

                ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
                at flash.display::DisplayObjectContainer/setChildIndex()
                at mx.core::Container/setChildIndex()[C:\autobuild\3.2.0\frameworks\projects\framework\src\m x\core\Container.as:2442]
                at com.esria.samples.dashboard.managers::PodLayoutManager/updateLayout()[C:\Documents and Settings\My Documents\Flex Builder 3\Dashboard\src\com\esria\samples\dashboard\managers\PodLayoutManager.as:471]
                at Dashboard/onCreationCompletePod()[C:\Documents and Settings\My Documents\Flex Builder 3\Dashboard\src\Dashboard.mxml:382]
                at flash.events::EventDispatcher/dispatchEventFunction()
                at flash.events::EventDispatcher/dispatchEvent()
                at mx.core::UIComponent/dispatchEvent()[C:\autobuild\3.2.0\frameworks\projects\framework\src \mx\core\UIComponent.as:9298]
                at mx.managers::LayoutManager/doPhasedInstantiation()[C:\autobuild\3.2.0\frameworks\projects \framework\src\mx\managers\LayoutManager.as:719]
                at Function/http://adobe.com/AS3/2006/builtin::apply()
                at mx.core::UIComponent/callLaterDispatcher2()[C:\autobuild\3.2.0\frameworks\projects\framew ork\src\mx\core\UIComponent.as:8628]
                at mx.core::UIComponent/callLaterDispatcher()[C:\autobuild\3.2.0\frameworks\projects\framewo rk\src\mx\core\UIComponent.as:8568]

                • 5. Re: DisplayObject must be a child of the caller.
                  Deeps45 Level 1

                  Please help me in fixing this.. Thanks in advance

                  • 6. Re: DisplayObject must be a child of the caller.
                    Flex harUI Adobe Employee

                    You will have to seek help from the PodLayoutManager folks.  It is their code that appears to be calling setChildIndex incorrectly, although it is possible that our oncCreationCOmpletePod() method is setting them up to fail.

                     

                    Alex Harui

                    Flex SDK Developer

                    Adobe Systems Inc.

                    Blog: http://blogs.adobe.com/aharui

                    1 person found this helpful
                    • 7. Re: DisplayObject must be a child of the caller.
                      *Prashant Shelke* Level 4

                      have you tried using


                      if( viewStack.getChildAt(viewStack.selectedIndex) ! =null && viewStack.getChildAt(viewStack.selectedIndex.children.length > 0)

                              viewStack.getChildAt(viewStack.selectedIndex.removeAllChildre();

                      1 person found this helpful
                      • 8. Re: DisplayObject must be a child of the caller.
                        Deeps45 Level 1

                        I tried someother way. The issue was fixed now.Thank you.

                        • 9. Re: DisplayObject must be a child of the caller.
                          Deeps45 Level 1

                          Hi,

                           

                          My application is working fine, but sometimes i get the following runtime error.

                          When i debugged it i find that the error is because of width parameter while creating rectangle.

                          width here is refering to UI.component width. the width value is coming as NAN.

                           

                          rc:Rectangle = new Rectangle(w, w, width - 2 * w, height - 2 * w);

                           

                           

                           

                           

                           

                          ArgumentError: Error #2004: One of the parameters is invalid.
                          at flash.display::Graphics/drawRect()
                          at qs.charts.renderers::RollOverBoxItemRenderer/updateDisplayList()[C:\Documents and Settings\dganeshan\My Documents\Flex Builder 3\RecoveryDashboard\src\qs\charts\renderers\RollOverBoxItemRenderer.as:138]
                          at mx.core::UIComponent/validateDisplayList()[C:\autobuild\3.2.0\frameworks\projec ts\framework\src\mx\core\UIComponent.as:6351]
                          at mx.managers::LayoutManager/validateDisplayList()[C:\autobuild\3.2.0\frameworks\ projects\framework\src\mx\managers\LayoutManager.as:622]
                          at mx.managers::LayoutManager/doPhasedInstantiation()[C:\autobuild\3.2.0\framework s\projects\framework\src\mx\managers\LayoutManager.as:695]
                          at Function/http://adobe.com/AS3/2006/builtin::apply()
                          at mx.core::UIComponent/callLaterDispatcher2()[C:\autobuild\3.2.0\frameworks\proje cts\framework\src\mx\core\UIComponent.as:8628]
                          at mx.core::UIComponent/callLaterDispatcher()[C:\autobuild\3.2.0\frameworks\projec ts\framework\src\mx\core\UIComponent.as:8568]

                           

                           

                          Please let me know if you have any idea about this problem.. Thanks in advance

                          var

                          • 10. Re: DisplayObject must be a child of the caller.
                            Deeps45 Level 1

                            Hi,

                             

                            My application is working fine, but sometimes i get the following runtime error.

                            When i debugged it i find that the error is because of width parameter while creating rectangle.

                            width here is refering to UI.component width. the width value is coming as NAN.

                             

                            rc:Rectangle = new Rectangle(w, w, width - 2 * w, height - 2 * w);

                             

                             

                             

                             

                             

                            ArgumentError: Error #2004: One of the parameters is invalid.
                            at flash.display::Graphics/drawRect()
                            at qs.charts.renderers::RollOverBoxItemRenderer/updateDisplayList()[C:\Documents and Settings\dganeshan\My Documents\Flex Builder 3\RecoveryDashboard\src\qs\charts\renderers\RollOverBoxItemRenderer.as:138]
                            at mx.core::UIComponent/validateDisplayList()[C:\autobuild\3.2.0\frameworks\projec ts\framework\src\mx\core\UIComponent.as:6351]
                            at mx.managers::LayoutManager/validateDisplayList()[C:\autobuild\3.2.0\frameworks\ projects\framework\src\mx\managers\LayoutManager.as:622]
                            at mx.managers::LayoutManager/doPhasedInstantiation()[C:\autobuild\3.2.0\framework s\projects\framework\src\mx\managers\LayoutManager.as:695]
                            at Function/http://adobe.com/AS3/2006/builtin::apply()
                            at mx.core::UIComponent/callLaterDispatcher2()[C:\autobuild\3.2.0\frameworks\proje cts\framework\src\mx\core\UIComponent.as:8628]
                            at mx.core::UIComponent/callLaterDispatcher()[C:\autobuild\3.2.0\frameworks\projec ts\framework\src\mx\core\UIComponent.as:8568]

                             

                             

                            Please let me know if you have any idea about this problem.. Thanks in advance

                            var