My guess is that there is no instance on the stage with the instance name mc_wall
, which is why you are getting the undefined property error. If there is not an instance name, then you cannot access it via an instance name, right ?
Next problem you will have though is that you CANNOT modify the name of a Timeline DisplayObject via code. So you will get this error even if you did name it something and then try to change it from that instance name :
The name property of a Timeline-placed object cannot be modified.
My thought is that you likely need to learn about arrays and not use the name
property as the way you manage collections of MovieClips such as your walls.
For instance, if I did have them on the timeline I'd put them inside another MovieClip , basically using it as a container for all my walls and name that instance "wall_container". Then in code I'd do this :
var walls:Array = new Array;
for (var index:int = 0;index < wall_container.numChildren;index++)
{
var wall:MovieClip = wall_container.getChildAt(index) as MovieClip;
walls.push(wall);
}
Now, if I wanted to access an individual wall, I can just go :
var wall:MovieClip = walls[5] as MovieClip;
or loop through all the walls to collision check or something I can go :
for (var index:int= 0;index < walls.length;index++)
{
var wall:MovieClip = walls[index] as MovieClip;
wall.x = 500;
wall.y = 200;
if (player.hitTestObject(wall))
{
}
}