5 Replies Latest reply: Apr 30, 2013 12:26 AM by LevkoYaskewych RSS

    List Item Renderers, State Changes, and Error #2025

    Anm_LA
      I keep getting the following error on apps that have lists with custom item renderers and state changes:
      quote:

      ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
      at flash.display::DisplayObjectContainer/removeChild()
      at mx.core::UIComponent/ http://www.adobe.com/2006/flex/mx/internal::$removeChild()
      at mx.core::UIComponent/removeChild()
      at mx.controls::SWFLoader/load()
      at mx.controls::SWFLoader/mx.controls:SWFLoader::commitProperties()
      at mx.core::UIComponent/validateProperties()
      at mx.managers::LayoutManager/validateClient()
      at mx.controls::List/mx.controls:List::makeRowsAndColumns()
      at mx.controls.listClasses::ListBase/mx.controls.listClasses:ListBase::updateDisplayList()
      at mx.controls::List/mx.controls:List::updateDisplayList()
      at mx.core::UIComponent/validateDisplayList()
      at mx.managers::LayoutManager/::validateDisplayList()
      at mx.managers::LayoutManager/::doPhasedInstantiation()
      at Function/ http://adobe.com/AS3/2006/builtin::apply()
      at mx.core::UIComponent/::callLaterDispatcher2()
      at mx.core::UIComponent/::callLaterDispatcher()



      Here is an example:
      http://www.anm.la.ca.us/transfers/ListItemRendererTest.swf
      http://www.anm.la.ca.us/transfers/ListItemRendererTestSrc.zip
      It contains a List with custom ItemRenderer inside a particular state view, and a button to change state. This error does not seem to appear without changing state.

      You can generate the error by following these steps:
      Add
      Change State
      Change State // Note the bitmap doesn't renderer
      Remove All
      Add // crash

      I have also seen the error on "Remove" and "Change State", but I can't come up with a reliable series of steps.

      Can anyone point out what I did wrong, or at least how I can avoid this error?
        • 1. Re: List Item Renderers, State Changes, and Error #2025
          supertimvanderh
          strange. Found out that it also occurs without changing state. I mean, starting from scratch randomly adding and removing states will result in a render error, after that add will result in the same error. Have you tried this without states?
          • 2. Re: List Item Renderers, State Changes, and Error #2025
            Anm_LA Community Member
            Okay. Yes. It does occur without a state change:
            Add
            Add
            Add
            Select 2nd
            Remove
            Select 2nd (was 3rd)
            Remove
            Add
            Add // Crash

            With that in mind, here is the list specific code:
            quote:

            ListRendererTest.mxml
            <mx:List id="char_list" editable="false"
            left="10" top="10" bottom="70" right="10"
            dataProvider="{characters}"
            itemRenderer="CharacterBriefRenderer"
            />

            // . . .
            [Bindable]
            public var characters:ArrayCollection = new ArrayCollection();

            public function add() :void {
            characters.addItem(
            new Character( "Character Name", new Portrait(), "Location", "Server" )
            );
            }

            public function remove() :void {
            var selected :Array = char_list.selectedItems;
            for each( var character :Object in selected ) {
            var index :int = characters.getItemIndex( character );
            characters.removeItemAt( index );
            }
            }

            public function removeAll() :void {
            characters.removeAll();
            }


            quote:

            CharacterBriefRenderer
            <mx:Canvas xmlns:mx=" http://www.adobe.com/2006/mxml"
            width="300" height="118">
            <mx:Image id="portrait" width="100" height="100" source="{data.Icon}" verticalCenter="0" left="8"/>
            <mx:VBox left="116" right="5" top="5" bottom="5" verticalGap="0">
            <mx:Text text="{data.FullName}" width="100%" fontWeight="bold" fontSize="14"/>
            <mx:Text text="{data.Location}" width="100%"/>
            <mx:Text text="{data.Server}" width="100%"/>
            </mx:VBox>
            </mx:Canvas>


            quote:

            Character.as
            // all the following have matching getters, without the underscore
            private var _name :String;
            private var _icon :Bitmap;
            private var _location :String;
            private var _server :String;


            • 3. Re: List Item Renderers, State Changes, and Error #2025
              Anm_LA Community Member
              I just realized the Character getter functions and inner private variables aren't exact matches, so here is the getter code:

              quote:

              Character.as
              public function get FullName() :String { return _name; }
              public function get Icon() :Bitmap { return _icon; }
              public function get Location() :String { return _location; }
              public function get Server() :String { return _server; }

              • 4. Re: List Item Renderers, State Changes, and Error #2025
                Anm_LA Community Member
                Still hoping for an answer. Does anyone have a clue about the above error?
                • 5. Re: List Item Renderers, State Changes, and Error #2025
                  LevkoYaskewych

                  When building a list on iOS, if you are using an image for instance in the overskin, the garbage collection fails while the list is moved rapidly. It CANNOT addChild and removeChild fast enough. You then get a 2025 error.

                  It will still run on a device but will lock up on rapid scroll making parts of the list fail to generate.

                  Drag scroll uses an image background to get the effect.

                   

                  The screen cannot dispose of the images and replace them to avoid overload of the memory if using large lists.

                   

                  Try using a stock standard list or grid without any changes to the look and feel.

                   

                  It should work. As for formatting the cells ...

                   

                  I am sure that Adobe will look into this in FLASH. They need to look at the cellrenderer overskin in the library and allow the overskin to be made available to format change just like every other element in the library.  THIS IS A BUG.