A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Why does Vector not inherit from Array?

  1. #1
    Senior Member
    Join Date
    May 2004
    Posts
    226

    Why does Vector not inherit from Array?

    1067: Implicit coercion of a value of type __AS3__.vec:Vector.<Foo> to an unrelated type Array.

    Really? Doesn't Vector include all the properties, methods and signatures of Array? Is there some low level reason Vector cannot be cast to Array?

  2. #2
    Junior Member
    Join Date
    Dec 2010
    Posts
    12
    Yes, there is a reason: Vector class is designed to be faster. Thats why it is created entirely from scratch.

  3. #3
    Senior Member
    Join Date
    May 2004
    Posts
    226
    Well, now I think about it, guess it is because Array is (still) a dynamic class where Vector is not.

    var array:Array = new Array();
    trace( array.foo ); //no compile error here

    var vector:Vector.<Object> = new Vector.<Object>();
    trace( vector.foo ); //will not compile

    But I wonder why adobe didn't define an interface, IArray or something.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center