3 Replies Latest reply on Sep 26, 2009 4:04 PM by paul.williams

    error TypeError: Error #1006: invalidateList is not a function. ?

    drillnaut

      Hello ,

        I am updating the data for a tree control. Whenever I call tree.invalidateDisplayList() or tree.invalidateList() , I always get an error saying that it isn't a function.  Has anyone seen this beast before , and if you slayed it , what did you use.


      Here is the offending code:

       

          public function click(event:Event):void
          {
              var object:Object = dataTree.openItems;
              dataTree.invalidateList();                              //Process kicks the bucket here
              xmlList = new XMLListCollection(xml2.user);
              dataTree.openItems = object;
          }

       

      Sincerely,

        D

        • 1. Re: error TypeError: Error #1006: invalidateList is not a function. ?
          paul.williams Level 4

          A full runnable example that demonstrates the problem would be great, but if you cannot do this then please post a full debug stack trace (with line-numbers). The problem could be due to a mistake elsewhere in your application. The invalidateList and invalidateDisplayList methods trigger general updates to the state of the component.

          • 2. Re: error TypeError: Error #1006: invalidateList is not a function. ?
            drillnaut Level 1

            Here is the code, you can drop it right into flex builder and go and see the exception throwing goodness.

             

            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:views="views.*">
                <mx:Script>
                <![CDATA[
                    import mx.collections.XMLListCollection;
                    import mx.controls.Tree;

             

             

                   [Bindable]
                    public var xmlList:XMLListCollection = new XMLListCollection(xml.user);

             

                   public function click(event:Event):void
                    {
                        var object:Object = dataTree.openItems;
                        dataTree.invalidateList();
                        xmlList = new XMLListCollection(xml2.user);
                        dataTree.openItems = object;
                    }

             


                    [Bindable]
                    public var xml:XML = XML(
            "<root><user username='Justin'>" +
                "<file fileId='1' name='Hogwarts' type='TOPDIRECTORY'>" +
                    "<file fileId='2' name='Voldemort' type='DIRECTORY'>" +
                        "<file fileId='3' name='Hermione' type='DIRECTORY'>" +
                            "<file fileId='4' name='Tolkien' type='FILE'/>" +
                            "<file fileId='5' name='J.R.R' type='FILE' />" +
                            "<file fileId='6' name='Books' type='DIRECTORY' >" +
                                "<file fileId='7' name='Shakespeare' type='FILE'/>" +
                            "</file>" +
                        "</file>" +
                    "</file>" +
                    "<file fileId='8' name='Power Rangers' type='DIRECTORY'>" +
                        "<file fileId='9' name='Good Guys' type='DIRECTORY'>" +
                            "<file fileId='10' name='Red Ranger' type='FILE' />" +
                            "<file fileId='11' name='Black Ranger' type='FILE' />" +
                            "<file fileId='12' name='Villains' type='DIRECTORY' >" +
                                "<file fileId='13' name='Madame Woe' type='FILE'/>" +
                            "</file>" +
                        "</file>" +
                    "</file>" +
                "</file>" +
            "</user>" +
            "<user username='Robby'>" +
                "<file fileId='1' name='Blade' type='TOPDIRECTORY'>" +
                    "<file fileId='2' name='Terminator' type='DIRECTORY'>" +
                        "<file fileId='3' name='Predator' type='DIRECTORY'>" +
                            "<file fileId='4' name='Robocop' type='FILE'/>" +
                            "<file fileId='5' name='Gremlins' type='FILE' />" +
                            "<file fileId='6' name='War and Peace' type='DIRECTORY' >" +
                                "<file fileId='7' name='Romeo and Juliet' type='FILE'/>" +
                            "</file>" +
                        "</file>" +
                    "</file>" +
                    "<file fileId='8' name='Toons' type='DIRECTORY'>" +
                        "<file fileId='9' name='Bugs Bunny' type='DIRECTORY'>" +
                            "<file fileId='10' name='Daffy Duck' type='FILE' />" +
                            "<file fileId='11' name='Elmer Fud' type='FILE' />" +
                            "<file fileId='12' name='Toxic Crusaders' type='DIRECTORY' >" +
                                "<file fileId='13' name='Gundam 00' type='FILE'/>" +
                            "</file>" +
                        "</file>" +
                    "</file>" +
                "</file>" +
            "</user></root>");

             

                    [Bindable]
                    public var xml2:XML = XML(
            "<root><user username='Justin'>" +
                "<file fileId='1' name='The A team' type='TOPDIRECTORY'>" +
                    "<file fileId='2' name='Voldemort' type='DIRECTORY'>" +
                        "<file fileId='3' name='Hermione' type='DIRECTORY'>" +
                            "<file fileId='4' name='Tolkien' type='FILE'/>" +
                            "<file fileId='5' name='J.R.R' type='FILE' />" +
                            "<file fileId='6' name='Books' type='DIRECTORY' >" +
                                "<file fileId='7' name='Shakespeare' type='FILE'/>" +
                            "</file>" +
                        "</file>" +
                    "</file>" +
                    "<file fileId='8' name='Power Rangers' type='DIRECTORY'>" +
                        "<file fileId='9' name='Good Guys' type='DIRECTORY'>" +
                            "<file fileId='10' name='Red Ranger' type='FILE' />" +
                            "<file fileId='11' name='Black Ranger' type='FILE' />" +
                            "<file fileId='12' name='Villains' type='DIRECTORY' >" +
                                "<file fileId='13' name='Madame Woe' type='FILE'/>" +
                            "</file>" +
                        "</file>" +
                    "</file>" +
                "</file>" +
            "</user>" +
            "<user username='Robby'>" +
                "<file fileId='14' name='Blade' type='TOPDIRECTORY'>" +
                    "<file fileId='15' name='Terminator' type='DIRECTORY'>" +
                        "<file fileId='16' name='Predator' type='DIRECTORY'>" +
                            "<file fileId='17' name='Robocop' type='FILE'/>" +
                            "<file fileId='18' name='Gremlins' type='FILE' />" +
                            "<file fileId='19' name='War and Peace' type='DIRECTORY' >" +
                                "<file fileId='20' name='Romeo and Juliet' type='FILE'/>" +
                            "</file>" +
                        "</file>" +
                    "</file>" +
                    "<file fileId='21' name='Toons' type='DIRECTORY'>" +
                        "<file fileId='22' name='Bugs Bunny' type='DIRECTORY'>" +
                            "<file fileId='23' name='Daffy Duck' type='FILE' />" +
                            "<file fileId='24' name='Elmer Fud' type='FILE' />" +
                            "<file fileId='25' name='Toxic Crusaders' type='DIRECTORY' >" +
                                "<file fileId='26' name='Gundam 00' type='FILE'/>" +
                                "<file fileId='27' name='Technoman' type='FILE'/>" +
                                "<file fileId='28' name='FullMetalAlchemist' type='FILE'/>" +
                            "</file>" +
                        "</file>" +
                    "</file>" +
                "</file>" +
            "</user></root>");

             

             

             

                ]]>
            </mx:Script>
            <mx:VBox width="100%" height="100%">
                <mx:Accordion width="100%" height="100%">
                    <mx:Repeater id="repeat" dataProvider="{xmlList}" >
                        <mx:VBox width="100%" height="100%" label="{repeat.currentItem.@username}">
                            <mx:Tree id="dataTree" labelField="@name" width="100%" height="100%"
                                     dataProvider="{repeat.currentItem.file}"/>
                        </mx:VBox>
                    </mx:Repeater>
                </mx:Accordion>
                <mx:Button id="clickMe" label="Change DataProvider" click="{click(event)}"/>
            </mx:VBox>
            </mx:Application>

            • 3. Re: error TypeError: Error #1006: invalidateList is not a function. ?
              paul.williams Level 4

              The error is thrown because dataTree is an array of Trees and this is because your Tree is declared in a repeater. You can access the individual trees using the dataTree[ 0 ], dataTree[ 1 ] etc. However, I'm not sure you need to invalidate the trees because the repeater will refresh after the click handler, causing the trees to be recreated.

               

              Also note that XML does not need to be declared as a String in Actionscript. The following will compile:

               

              [Bindable]
              public var xml2:XML =

                   <root>

                        <user username='Justin'>
                            <file fileId='1' name='The A team' type='TOPDIRECTORY'>

                        </user>

                   </root>;