1:class TestCasting 2:{ 3: function TestCasting() 4: { 5: // if you uncomment the code below (remove only these /**/), you will get the mismatch error 6: /* 7: var c:Container = new Container(new Array()); 8: var i:Array = c.getItem(); 9: 10: //Error: Type mismatch in assignment statement: 11: //found Object where Array is required. 12: //var i:Array = c.getItem(); 13: */ 14: test1(); 15: test2(); 16: test3(); 17: test4(); 18: } 19: 20: function test1() 21: { 22: var c:Container = new Container(new Array()); 23: var i:Array = (Array)(c.getItem()); 24: trace(i instanceof Array);// return true 25: } 26: function test2() 27: { 28: var c:Container = new Container(new Array()); 29: var i:Array = Array(c.getItem()); 30: trace(i instanceof Array);// return true 31: } 32: function test3() 33: { 34: var c:Container = new Container(new Item()); 35: var i:Item = Item(c.getItem()); 36: trace(i instanceof Item);// return true 37: } 38: function test4() 39: { 40: var c:Container = new Container(new Item()); 41: var i:Item = (Item)(c.getItem()); 42: trace(i instanceof Item);// return false 43: trace(i instanceof Object);// return false 44: trace(i == undefined)// return true 45: } 46:}