moving enemy to a random available tile
I have an enemy hitting a bunch of tiles, and through a loop, I check all the tiles if the enemy is hitting them. I trace them and some will tell me if it's true or false. Although you can't see tileset, it is an array that is equal to a movieclip that is a tile. It is in a for loop itself, so basically, tileset is 49 movie clips of tile. I want to be able to get the enemy to randomly choose from those that are true, and go on those tiles. It traces all the tiles that are in contact with the enemy, and I push those into another array called options. Below is my timer function, where every 5 second, I want the enemy to move to an available tile. My problem is, I'm not sure how I can get the enemy to move randomly into those available tiles.
function timerenemy (event:TimerEvent) {
var options:Array = [];
for (var j:int = 0; j < tileset.length; j++){
if (tileset
tileset
options.push(tileset
}
if (options.length > 0){
var enemyPick:int = Math.floor(Math.random()*options.length)
}
}
trace(enemyPick, options);
}