4 Replies Latest reply on Aug 9, 2010 2:25 AM by BhaskerChari

    Declaring the var in the constructer

    nikos101 Level 2

      How can someone do this without declaring the photos var before the constructer as a field?

       


      package org.robotlegs.demos.imagegallery.models.vo
      {
          import mx.collections.ArrayCollection;

       

          [Bindable]
          public class Gallery
          {

              public var photos:ArrayCollection = new ArrayCollection()

          }
      }

        • 1. Re: Declaring the var in the constructer
          BhaskerChari Level 4

          What is your exact idea behind your question I dint get it...??

           

          Whats the problem in there for you ...by declaring the varible outside and before the constructor..??

           

          Please elaborate on this...

           

          Thanks,

          Bhasker Chari

          • 2. Re: Declaring the var in the constructer
            nikos101 Level 2

            We'll im used to declaring fields here out side the constructor

             

             

                    public var photos:

             

                [Bindable]
                public class Gallery
                {


            • 3. Re: Declaring the var in the constructer
              BhaskerChari Level 4

              Hi Nikos,

               

              By your saying that the declaring fields here out side the constructor..Do you really mean it...why because in your code you doesn't seem to have a

               

              constructor and you are actually trying to declare the variable outside the class infact but not outside the constructor..

               

               

              So you are trying to do the follwing which is wrong..:

               

              //Here you are declaring the variable outside the class indeed which is wrong..

              package org.robotlegs.demos.imagegallery.models.vo
              {
                   import mx.collections.ArrayCollection;
                  
                   public var photos:ArrayCollection = new ArrayCollection()
                  
                   [Bindable]
                   public class Gallery
                   {
                      
                   }
              }

               

               

              Infact you should do this ....

               

              package org.robotlegs.demos.imagegallery.models.vo
              {
                   import mx.collections.ArrayCollection;
                  
                   [Bindable]
                   public class Gallery
                   {
                       public var photos:ArrayCollection = new ArrayCollection()
                      
                       //Your Constructor
                       public function Gallery()
                    {
                    
                    }
                   }
              }

               

              Hope you understood my point....

               

              Thanks,

              Bhasker Chari

              • 4. Re: Declaring the var in the constructer
                nikos101 Level 2

                sigh.....please ignore me I'm getting confused with mxml