12 Replies Latest reply on Oct 15, 2008 5:23 AM by orange_m

    How to enumerate list items

    orange_m Level 1
      Hello

      I have two lists, one is populated with list of IPs from DB by httprequest, and another one is empty and accepting drag and drop for the first list.

      Now, I would like to enumerate all dropped IPs in that second list.

      Does anyone can advice me how to do that?

      Thnx
        • 1. Re: How to enumerate list items
          Level 7

          "orange_m" <webforumsuser@macromedia.com> wrote in message
          news:gd2ktv$8st$1@forums.macromedia.com...
          > Hello
          >
          > I have two lists, one is populated with list of IPs from DB by
          > httprequest,
          > and another one is empty and accepting drag and drop for the first list.
          >
          > Now, I would like to enumerate all dropped IPs in that second list.
          >
          > Does anyone can advice me how to do that?

          list2.dataProvider...?


          • 2. Re: How to enumerate list items
            orange_m Level 1
            Can you tell me more in details what to do with dataProvider?
            • 3. Re: How to enumerate list items
              Level 7

              "orange_m" <webforumsuser@macromedia.com> wrote in message
              news:gd2nqh$ca5$1@forums.macromedia.com...
              > Can you tell me more in details what to do with dataProvider?

              What kind of dataProvider is it?


              • 4. Re: How to enumerate list items
                orange_m Level 1
                <mx:List id="ips" height="285" width="173"
                allowMultipleSelection="true"
                dragEnabled="true" dragMoveEnabled="true" dropEnabled="true">
                </mx:List>

                It`s an ordinary list control.

                I just need to access all items dropped inside...put them in Array for example.
                • 5. Re: How to enumerate list items
                  Level 7

                  "orange_m" <webforumsuser@macromedia.com> wrote in message
                  news:gd2t62$ij7$1@forums.macromedia.com...
                  > <mx:List id="ips" height="285" width="173"
                  > allowMultipleSelection="true"
                  > dragEnabled="true" dragMoveEnabled="true"
                  > dropEnabled="true">
                  > </mx:List>
                  >
                  > It`s an ordinary list control.
                  >
                  > I just need to access all items dropped inside...put them in Array for
                  > example.

                  The other List that you have...what type is _its_ dataProvider?


                  • 6. Re: How to enumerate list items
                    orange_m Level 1
                    It`s same like the one I`ve posted:

                    <mx:List id="ips_list"
                    width="194" height="287"
                    allowMultipleSelection="true"
                    dragEnabled="true"
                    dragMoveEnabled="true"
                    dropEnabled="true" >
                    </mx:List>

                    Data provider for this list is XML(httprequest) in this format
                    <ips>
                    <ip>127.0.0.1</ip>
                    <ip>127.0.0.2</ip>
                    <ip>127.0.0.3</ip>
                    </ips>

                    ips_list.dataProvider = event.result.ips;

                    For preview these IPs in list, I`m using ItemRenderer

                    <?xml version="1.0" encoding="utf-8"?>
                    <mx:HBox xmlns:mx=" http://www.adobe.com/2006/mxml">
                    <mx:Label id="ip" text="{data.ip}"/>
                    </mx:HBox>
                    • 7. Re: How to enumerate list items
                      Level 7

                      "orange_m" <webforumsuser@macromedia.com> wrote in message
                      news:gd3296$obk$1@forums.macromedia.com...
                      > It`s same like the one I`ve posted:
                      >
                      > <mx:List id="ips_list"
                      > width="194" height="287"
                      >
                      > allowMultipleSelection="true"
                      > dragEnabled="true"
                      > dragMoveEnabled="true"
                      > dropEnabled="true" >
                      > </mx:List>
                      >
                      > Data provider for this list is XML(httprequest) in this format
                      > <ips>
                      > <ip>127.0.0.1</ip>
                      > <ip>127.0.0.2</ip>
                      > <ip>127.0.0.3</ip>
                      > </ips>
                      >
                      > ips_list.dataProvider = event.result.ips;
                      >
                      > For preview these IPs in list, I`m using ItemRenderer
                      >
                      > <?xml version="1.0" encoding="utf-8"?>
                      > <mx:HBox xmlns:mx=" http://www.adobe.com/2006/mxml">
                      > <mx:Label id="ip" text="{data.ip}"/>
                      > </mx:HBox>
                      >

                      You can't really drag and drop XML like that. You need to clone the nodes.
                      See http://tinyurl.com/4p88eq


                      • 8. Re: How to enumerate list items
                        ntsiii Level 3
                        Hold on, drag and drop works with xml. At least I think I have done that, though I almost always use a collection for lists.

                        Orange, is your drag and drom stuff working correctly? Post the declaration for the target list.

                        You should be able to iterate over it something like:
                        var xlTarget:XMLList = myTargetList.dataProvider;
                        for (var i:int = o;i<xlTarget.length();i++) {
                        trace("target ip: " + xlTarget [ i ].text()); //extra spaces to stop forum software from mangling code

                        Tracy
                        • 9. Re: How to enumerate list items
                          orange_m Level 1
                          My drag and drop works perfect.

                          ntsiii, I have tried your itteration suggestion, but I can`t complie it.

                          Getting this error:
                          1118: Implicit coercion of a value with static type Object to a possibly unrelated type XMLList.

                          That is for this code segment:
                          var xlTarget:XMLList = myTargetList.dataProvider;
                          • 10. Re: How to enumerate list items
                            ntsiii Level 3
                            That error means you are not using and XMLList as your dataProvider.

                            I need to see your HTTPService declaration, and the declaration of the target List.

                            Also post the full code of the iteration loop.

                            USE THE ATTACH CODE functionality please.

                            Tracy
                            • 11. Re: How to enumerate list items
                              ntsiii Level 3
                              I also need to see your result handler function.
                              • 12. Re: How to enumerate list items
                                orange_m Level 1
                                Thank you for help, but I have found solution:

                                var objTest:Object = ips.dataProvider;

                                for (var strTest:String in objTest)
                                {
                                mx.controls.Alert.show(objTest[strTest].ip);
                                }