4 Replies Latest reply on Feb 16, 2010 7:57 PM by Gregory Lafrance

    bidimensional array

    eranweingart

      hi

      sorry about this question, but i'm new to flex.

      how do i declare a bidimensional array?

        • 1. Re: bidimensional array
          Jason Szeto Level 3

          I don't think you can declare a multi-dimensional array. This is how I usually create mine:

           

                         var outer:Array = new Array();
                         
                          for (var i:int = 0; i < 10; i++)
                          {
                              var inner:Array = new Array();
                              outer[i] = inner;
                          }

           

           

          Jason

          • 2. Re: bidimensional array
            Gregory Lafrance Level 6

            Sure you can:

             

            http://livedocs.adobe.com/flex/3/html/help.html?content=10_Lists_of_data_5.html

             

            If this post answers your question or helps, please mark it as such.


            Greg Lafrance - Flex 2 and 3 ACE certified

            www.ChikaraDev.com

            Flex / AIR Development, Training, and Support Services

            • 3. Re: bidimensional array
              Jason Szeto Level 3

              Greg,

               

              I think the original poster asked if there was a way to declare a two-dimensional array with a single declaration as you can in other languages.

               

              int[][] x = new int[3][5];

               

              It is not possible to do this in Actionscript, as far as I know.

               

              But thanks for digging up that link.

               

              Jason

              • 4. Re: bidimensional array
                Gregory Lafrance Level 6

                You can do this:

                 

                <?xml version="1.0" encoding="utf-8"?>
                <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
                  <mx:Script>
                    <![CDATA[
                      private var arr:Array = [
                        ["1", "2", "3"], ["10", "20", "30"], ["100", "200", "300"]
                      ];
                    ]]>
                  </mx:Script>
                  <mx:HBox>
                    <mx:ComboBox dataProvider="{arr[0]}"/>
                    <mx:ComboBox dataProvider="{arr[1]}"/>
                    <mx:ComboBox dataProvider="{arr[2]}"/>    
                  </mx:HBox>
                </mx:Application>
                


                If this post answers your question or helps, please mark it as such.


                Greg Lafrance - Flex 2 and 3 ACE certified

                www.ChikaraDev.com

                Flex / AIR Development, Training, and Support Services