Created
July 12, 2011 13:47
-
-
Save fljot/1078004 to your computer and use it in GitHub Desktop.
[AS3] Vector.<*> as argument
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var v:Vector.<Sprite> = new Vector.<Sprite>(); | |
trace(v is Vector.<*>);// true | |
var foo:Vector.<*>; | |
//foo = v;// Implicit coercion of a value of type __AS3__.vec:Vector.<flash.display:Sprite> to an unrelated type __AS3__.vec:Vector.<*>. | |
foo = v as Vector.<*>; // OK | |
var bar:Vector.<Sprite> = foo as Vector.<Sprite>;// OK | |
genericArgument(v);// true, 0, Hello from genericArgument() | |
//typedArgument(v);// Implicit coercion of a value of type __AS3__.vec:Vector.<flash.display:Sprite> to an unrelated type __AS3__.vec:Vector.<*>. | |
function genericArgument(value:*):void | |
{ | |
var foo:Vector.<*> = value as Vector.<*>; | |
trace(foo is Vector.<*>, foo.length); // true, 0 | |
trace("Hello from genericArgument()"); | |
} | |
function typedArgument(value:Vector.<*>):void | |
{ | |
trace("You won't see this message"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This seems to work for Vector. but not Vector.. I guess primitive types don't work...