I've got a handful of levels, with a character you can control and x amounts of blocks in each level.
I need a good way to hitTest each block without having to write a if case for each and every one of them.
What i got now are 1 player on the scene and 2 blocks named wall_1 and wall_2:
var walls:Array = ['wall_1','wall_2'];
var walls_length:int = walls.length;
for(var i:int = 0; i < walls_length; i++){
if( player.hitTestObject( walls[i] ) ){
trace("you hit: " + walls[i]);
}}
But hitTestObject doesn't take too kindly to array values.
Instead i get an: Error #1034: Type Coercion failed: cannot convert "wall_1" to flash.display.DisplayObject.
Any ideas?