9 Replies Latest reply on Apr 20, 2010 10:23 PM by FinFlex

    var varible:*

    FinFlex Level 1

      Simple question, what does that mean? What is the type of variable?

        • 1. Re: var varible:*
          levancho Level 3

          it is untyped varialbe that means it has no type, you can asign anything to it, number, string etc etc ..

          • 2. Re: var varible:*
            Matt Le Fevre Level 4

            i imagine it's similar to the imports you see such as

             

            import mx.effects.easing.*;


            which acts as an ambiguous reference including everything.

             

             

             

            so

             

            var whatever:*;

             

            would result in a variable that hasn't been given a definitive type, and could act as anything

            1 person found this helpful
            • 3. Re: var varible:*
              Sebastien V. Level 3

              The import * can be usefull if you want to import every classes in a package, this does not seem ambiguous to me.

               

              The * used as a var or function return type, however, I wouldn't use.

              First because every AS3 class extends the Object class. So if you do not want a typed object you can use the Object class as a type.

              Then because the * type does not only allow object values, but everything (including undefined).

               

              BTW for first poster, an equivalent to var v:*; is var v; (with no type at all).

              • 4. Re: var varible:*
                vijay_p4u

                Did anyone try this? I guess this results in compilation error "A type identifier is expected after the ':'".

                 

                A variable can be declared un-typed as below.

                 

                     var varible;

                 

                Thanks & Regards,

                Vijay

                • 5. Re: var varible:*
                  levancho Level 3

                  Var variable - is very bad practice to do that kind of declarations in as3

                  You are basically forcing backward compartability, 

                  You should do var variable:*

                   

                  Same as using dynamic events, all that is a heavy burden on avm

                   

                   

                   

                  -- Sent from my Palm Pre

                  On Apr 20, 2010 10:25 AM, vijay_p4u <forums@adobe.com> wrote:

                   

                  Did anyone try this? I guess this results in compilation error "A type identifier is expected after the ':'".

                   

                   

                   

                  A variable can be declared un-typed as below.

                   

                   

                   

                       var varible;

                   

                   

                   

                  Thanks & Regards,

                   

                  Vijay

                  • 6. Re: var varible:*
                    GordonSmith Level 4

                    Declaring

                     

                        var myvar;

                     

                    and

                     

                        var myvar:*;

                     

                    are equivalent at runtime. Neither one provides the performance advantages of "strong typing" that you get when you do something like

                     

                        var myvar:MyClass;

                     

                    The only difference is that the compiler normally warns when you omit a type annotation, and the * prevents the warning.

                     

                    Gordon Smith

                    Adobe Flex SDK Team

                    • 7. Re: var varible:*
                      levancho Level 3

                      That means var a:* can be undefined? I tought undefined has ben removed 

                       

                       

                       

                      -- Sent from my Palm Pre

                      On Apr 20, 2010 2:35 PM, GordonSmith <forums@adobe.com> wrote:

                       

                      Declaring

                       

                       

                       

                          var myvar;

                       

                       

                       

                      and

                       

                       

                       

                          var myvar:*;

                       

                       

                       

                      are equivalent at runtime. Neither one provides the performance advantages of "strong typing" that you get when you do something like

                       

                       

                       

                          var myvar:MyClass;

                       

                       

                       

                      The only difference is that the compiler normally warns when you omit a type annotation, and the * prevents the warning.

                       

                       

                       

                      Gordon Smith

                       

                      Adobe Flex SDK Team

                      1 person found this helpful
                      • 8. Re: var varible:*
                        GordonSmith Level 4

                        > That means var a:* can be undefined? I tought undefined has ben removed

                         

                        The 'undefined' value is a legal value in AS3. But it can be stored only in untyped variables (i.e., those indicated by a * type annotation, or those lacking a type annotation). The Object type, for example, cannot store 'undefined'.

                         

                        As an example of * and 'undefined', the return type of getStyle() is *, and it will return 'undefined' if no style value is found in the style lookup chain.

                         

                        Gordon Smith

                        Adobe Flex SDK Team

                        • 9. Re: var varible:*
                          FinFlex Level 1

                          Thank you. This is loud and clear.