# AS3 - test if character is still on the line

**URL:** <https://forum.kirupa.com/t/as3-test-if-character-is-still-on-the-line/305185>\
**Category:** flash\
**Created:** [February 20, 2010, 4:04pm UTC](https://forum.kirupa.com/t/as3-test-if-character-is-still-on-the-line/305185 "2010-02-20T16:04:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gooo](https://avatars.discourse-cdn.com/v4/letter/g/eb8c5e/32.png) [@Gooo](https://forum.kirupa.com/u/Gooo)\
**Post date:** [February 20, 2010, 4:04pm UTC](https://forum.kirupa.com/t/as3-test-if-character-is-still-on-the-line/305185/1 "2010-02-20T16:04:23Z")

</div>

Hi

I’m designing a maze type of game. The character can only walk on a line. I’m trying to test if the character is on the line (land). If he isn’t on the line, he isn’t supposed to move (i.e. disable the arrows that control him).

The easiest way I thought to test this, is to test the color the character is on. (The line is “66CC00” and the rest is “999999”).

My code:

```auto
var land:Boolean = false;
var bmp:BitmapData = new BitmapData(this.width, this.height, false);
bmp.draw(this);
var pColor:Number = bmp.getPixel(character1_mc.x, character1_mc.y);
var hexColor:String;

stage.addEventListener(Event.ENTER_FRAME, color);
function color(event:Event):void
{
    hexColor = pColor.toString(16).toUpperCase();
    while(hexColor.length < 6){
        hexColor = "0" + hexColor;
    }

    if(hexColor == "66CC00")
    {
        land = true;
    }
    else if(hexColor == "999999")
    {
        land = false;
    }
}

```

My character stands on “66CC00” in the beginning, so that he can start moving. When I trace hexColor it stays on “66CC00” even though my character moves onto “999999”.

What am I doing wrong?
