Skip navigation
smagfx2
Currently Being Moderated

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

Jul 29, 2010 3:20 PM

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. 

 
Replies
  • Currently Being Moderated
    Jul 30, 2010 12:40 PM   in reply to smagfx2

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 26, 2010 12:57 PM   in reply to GordonSmith

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 29, 2013 5:50 AM   in reply to smagfx2

    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 )

      {

        vector.pop();

      }

      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...

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points