I'm fairly new to flash and action script 3.0 but I've had a project to create maze game, I've made the maze on a layer, player on a layer, the decor on a layer and then an enemy, the player maze, and points system all work fine, but i have no idea how to implement the following of the player with an enemy and to keep the enemy within the maze like I've done with the player, the symbol is named enemy so if anyone could help me out how this to my code it would be appreciated this is my entire code:

Code:
var rightArrow:Boolean = false; 
    var leftArrow:Boolean = false;
    var upArrow:Boolean = false;
    var downArrow:Boolean = false;
    
    var dKey:Boolean = false;   
    var aKey:Boolean = false;
    var wKey:Boolean = false;
    var sKey:Boolean = false;
    
    var speed :int = 5;
    var coins :Array = [ coin1, coin2, coin3, coin4, coin5, coin6, coin7, coin8, coin9, specialCoin ];
    var score :Number = 0;
    
    stage.addEventListener(KeyboardEvent.KEY_DOWN, stage_onKeyDown);
    stage.addEventListener(KeyboardEvent.KEY_UP, stage_onKeyUp);
    stage.addEventListener(Event.ENTER_FRAME, stage_onEnterFrame);

    function stage_onKeyDown(event:KeyboardEvent):void {
        if(event.keyCode == Keyboard.RIGHT) rightArrow = true;
        if(event.keyCode == Keyboard.LEFT) leftArrow = true;
        if(event.keyCode == Keyboard.UP) upArrow = true;
        if(event.keyCode == Keyboard.DOWN) downArrow = true;
    }
    function stage_onKeyUp(event:KeyboardEvent):void {
        if(event.keyCode == Keyboard.RIGHT) rightArrow = false;
        if(event.keyCode == Keyboard.LEFT) leftArrow = false;
        if(event.keyCode == Keyboard.UP) upArrow = false;
        if(event.keyCode == Keyboard.DOWN) downArrow = false;
    }
    function stage_onEnterFrame(event:Event):void {
        var rect:Rectangle = player.getBounds(this);
        var i:int = 0;
        var xBump:int = 0;
        var yBump:int = 0;
        if(rightArrow) {
            xBump = speed;
            for(i = 0; i < speed; i++) {
                if(maze.hitTestPoint(rect.right + i, player.y, true)) {
                    xBump = i - 1;
                    break;
                }
                player.gotoAndStop ("Right");
            }
        }
        if(leftArrow) {
            xBump = -speed;
            for(i = 0; i < speed; i++) {
                if(maze.hitTestPoint(rect.left - i, player.y, true)) {
                    xBump = -i + 1;
                    break;
                }
                player.gotoAndStop ("Left");
            }
        }
        if(upArrow) {
            yBump = -speed;
            for(i = 0; i < speed; i++) {
                if(maze.hitTestPoint(player.x, rect.top - i, true)) {
                    yBump = -i + 1;
                    break;
                }
                player.gotoAndStop ("Up");
            }
        }
        if(downArrow) {
            yBump = speed;
            for(i = 0; i < speed; i++) {
                if(maze.hitTestPoint(player.x, rect.bottom + i, true)) {
                    yBump = i - 1;
                    break;
                }
                player.gotoAndStop ("Down");
            }
        }
        player.x += xBump;
        player.y += yBump;
        
        for ( var c:int = 0; c < coins.length; c++)
    {
        if ( coins[c].visible && 
            coins[c].hitTestObject( player )
            )
        {
            if (coins[c] == specialCoin)
            {
                score += 5;
                speed += 5; // power-up
            }
            else
                score++; 
                
            coins[c].visible = false;
            scoreText.text = "Score:" + score;
        
        }
    }
    
    }