3 Replies Latest reply on Jan 29, 2013 5:50 AM by derRaab();

    Untyped vector - Vector.<*> performance & error question

    smagfx2 Level 1

      Is there anything in the language reference about untyped Vector objects in ActionScript/Flex? Would there still be performance gains over Array by using:



      var vec:Vector.<*> = new Vector.<*>();



      I'm also wondering if this is valid, because I got occasional compiler errors when using it. I haven't yet been able to reproduce the error consistently but this is what is reported:



      1046: Type was not found or was not a compile-time constant: .     



      Note the end of the error message where the type name should be. Flash Builder 4 also reports the location as "Unknown". (This error happens with a command line ant/mxmlc build too.) I'm using Flex 4.1.


      Here's the actual code that seems to be causing the error:



      protected var children:Vector.<*>;
      // ...
      children = new Vector.<*>();


      EDIT: This is the error that I get with a command line build.


      [mxmlc] Error: Type was not found or was not a compile-time constant: Vector. 

        • 1. Re: Untyped vector - Vector.<*> performance & error question
          GordonSmith Level 4

          If you manage to repro the problem, please file it as a bug.


          If you don't need to be able to store undefined as an element value, try using Vector.<Object> instead of Vector.<*>.


          Gordon Smith

          Adobe Flex SDK Team

          • 2. Re: Untyped vector - Vector.<*> performance & error question
            JTtheGeek Level 1

            I get this compiler error all the freaking time on a large scale application whenever I use Vector.<*> as a return type on a function inside a Flex 4 Library project, and attempt to use that function in the main Flex 4 project.  Vector.<Object> dosen't work here as a return type as I get cast conversion errors.  Only thing that seems to work at all is just *, but then that bypasses vector type checking during compile time which also ins't ideal.  Oh well, another problem due to the half baked implementation of vector's by the player team.   It's really frustrating not being able to write generic list functions, work with vector interfaces, and in generally write any sort of re-suable code using vectors with out just putting *'s everywhere and praying.   Isn't this the whole point of vectors was for type-safety?      I wish Adobe would take a few clues from c# already.

            • 3. Re: Untyped vector - Vector.<*> performance & error question

              Damn, this problem is bothering me since years but finally I found at least a note about it here. Within my private library I have a VectorUtil class which does some tasks like removing all items or only push one item if it's not already in the vector instance.


              public static function lengthMax( vector : Vector.<*>, length : uint ) : Vector.<*>


                while ( length < vector.length )




                return vector;



              Usually it works as expectet but sometimes I get weird compile time errors, then I need to clean the flex compiler an recompile everything.


              But now I need to provide a precompiled SWC to other developers but compiling separate projects doesn't work at all. Since using Vector.<Object> results in different type casting errors I hopefully will fix this by not typing vector at all. But that is definitely annoying! It would be really great if somebody could check the Vector implementation...