8 Replies Latest reply on Oct 6, 2008 8:22 PM by Newsgroup_User

    array of strings

    ice9_us Level 1
      trying to trace out data to add into arrays of strings for a data grid...

      xml:
      <tkt>
      <servname></servname>
      <notes user="someuser" date="somedate"></notes>
      </tkt>

      when a user updates the notes it will keep a log.. so i will have more than 1 entry for <notes></notes>

      I am reading this info.. into an array and trying to put it into an array for use in a "editable" data grid..
      showing all info...

      if i
      trace(event.target.selectedItem.HDLogData);

      i get both strings split up with a " , "
      i tried to use the " , " to split up the string into an array of strings, but no luck...

      I then wanted to try this little bit .. but no luck either..

      for ( var a:int=0; a <= event.target.selectedItem.HDLogData.length; a++ ) {
      //hdnotes[a] = event.target.selectedItem.HDLogData.source[a];
      trace(event.target.selectedItem.HDLogData[a]);
      }

      when i trace here.. i get errors..

      [SWF] C:\Users\ray\Documents\Flex Builder 3\genesis\bin-debug\genesis.swf - 1,338,719 bytes after decompression
      ReferenceError: Error #1069: Property 0 not found on String and there is no default value.
      at genesis/switchit()[C:\Users\ray\Documents\Flex Builder 3\genesis\src\genesis.mxml:62]
      at genesis/__hdGrid_change()[C:\Users\ray\Documents\Flex Builder 3\genesis\src\genesis.mxml:83]
      at flash.events::EventDispatcher/dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at mx.core::UIComponent/dispatchEvent()[E:\dev\3.1.0\frameworks\projects\framework\src\mx\co re\UIComponent.as:9156]
      at mx.controls.listClasses::ListBase/mouseUpHandler()[E:\dev\3.1.0\frameworks\projects\frame work\src\mx\controls\listClasses\ListBase.as:8984]
      at mx.controls::DataGrid/mouseUpHandler()[E:\dev\3.1.0\frameworks\projects\framework\src\mx\ controls\DataGrid.as:4332]


      Debugger shows hdlogdata has the length of 2.. and hdlogdata.0 = string 1
      hdlogdata.1 = string2

      any ideas on this...


      <mx:DataGrid x="44" dataProvider="{hdnotes}" y="247">
        • 1. Re: array of strings
          Gregory Lafrance Level 6
          What is HDLogData?

          Maybe simplified yet "complete" code so we can work this out?
          • 2. Re: array of strings
            ice9_us Level 1
            part of my xml data.. which i read into an array list..



            <tkt>
            <servname></servname>
            <HDLogData user="someuser" date="somedate"></HDLogData>
            <HDLogData user="someuser" date="somedate"></HDLogData>
            <HDLogData user="someuser" date="somedate"></HDLogData>
            </tkt>
            • 3. Re: array of strings
              ice9_us Level 1
              files with Several HDLogData entries.. the arraylist works..
              when trying to understand if i have an array list i try to source

              event.arget.selectedItem.HDLogData.length

              if it is an array it gives me the correct number of HDLogData entries; however, if it is just 1 entry it gives me the length of the entry.

              Anyone know a way around this...

              • 4. Re: array of strings
                Level 7

                "ice9_us" <webforumsuser@macromedia.com> wrote in message
                news:gcdej1$f0m$1@forums.macromedia.com...
                > files with Several HDLogData entries.. the arraylist works..
                > when trying to understand if i have an array list i try to source
                >
                > event.arget.selectedItem.HDLogData.length
                >
                > if it is an array it gives me the correct number of HDLogData entries;
                > however, if it is just 1 entry it gives me the length of the entry.
                >
                > Anyone know a way around this...

                The FlexCoder FAQ (which mostly seems to date back to 1.5) suggests that the
                answer to this is to set the resultFormat to Object. Tracy usually says set
                the resultFormat to e4X. You can try both and tell us what worked for you
                :-)


                • 5. Re: array of strings
                  ice9_us Level 1


                  Amy,
                  where is the FAQ can you post a link? The online docu.. didn't offer any info for a way to do this...
                  I am not sure how it works with the e4x I may try it.

                  thanks in advanced.
                  • 6. Re: array of strings
                    ice9_us Level 1
                    Well.. i have found 3 ways to do this... The best way was to change my format to e4x

                    when people slect the data grid column take that event and put it in to a XMLList..
                    move that to a XMLListCollection and use that as my dataProvider...

                    myLogdata = event.target.selectedItem.HDLogData;
                    hdnotes.source = myLogdata;

                    var myLogdata:XMLList = new XMLList();
                    public var hdnotes:XMLListCollection = new XMLListCollection();

                    this has yielded the best results..

                    i was using the split() function to split a string....
                    based on the return of that being null or not.. I was able to push that in text onto a display for viewing..

                    both work fine.. splitting the values wasn't the fastest way of doing things...
                    I am just goofing off, but i could imagion if you have a very large number of entries.. splitting the string is going to rather hard to keep up with...

                    • 7. Re: array of strings
                      ice9_us Level 1
                      sorry.. 3rd way was placeing the data into a text value
                      and having all of it crunched into one string... in a text field for display...

                      not the best looking thing, but it worked :?)
                      • 8. Re: array of strings
                        Level 7

                        "ice9_us" <webforumsuser@macromedia.com> wrote in message
                        news:gce8lr$hmi$1@forums.macromedia.com...
                        >
                        >
                        > Amy,
                        > where is the FAQ can you post a link? The online docu.. didn't offer any
                        > info for a way to do this...
                        > I am not sure how it works with the e4x I may try it.

                        I think you have to join the yahoo FlexCoders group to be able to see it,
                        but here's the direct link if you can get it:
                        http://tech.groups.yahoo.com/group/flexcoders/files/