# getPixel() - Not getting pixel

**URL:** <https://forum.kirupa.com/t/getpixel-not-getting-pixel/280748>\
**Category:** programming\
**Created:** [January 31, 2009, 7:43am UTC](https://forum.kirupa.com/t/getpixel-not-getting-pixel/280748 "2009-01-31T07:43:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Skribble](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@Skribble](https://forum.kirupa.com/u/Skribble)\
**Post date:** [January 31, 2009, 7:43am UTC](https://forum.kirupa.com/t/getpixel-not-getting-pixel/280748/1 "2009-01-31T07:43:42Z")

</div>

**Explanation:**

I made a post a little while ago about potentially using getPixel to refine my hitTests; using different colors to garner different reactions from certain MC’s. So I started playing around with it, and drawing vectors as bitmaps, but I’ve now hit a snag.

I have this script located on ROOT:  
[SIZE=1]  
_[g being the “ground” movieclip]_[/SIZE]

```auto
import flash.display.BitmapData;
var gBit:BitmapData = new BitmapData(_root.g._width,_root.g._height);
gBit.draw(_root.g);

```

And this script located on a section of the heros script:

[i being a loop I’m using for one of the heros functions]

```auto
_root.gPixelX = _root.hero._x-_root.g._x;
_root.gPixelY = (_root.hero._y+i)-_root.g._y;
trace("heros X pixel = "+_root.gPixelX);
trace("heros Y pixel = "+_root.gPixelY);
_root.gPixel = _root.gBit.getPixel(gPixelX,gPixelY).toString(16);
trace("Pixel Color = "+_root.gPixel);

```

I assumed this would work, but for some reason I cannot even trace my original bitmapData, “gBit”, and it just shows up as [object Object] in a trace.

\*\*Question:  
\*\*  
What am I doing wrong here? This is new territory for me and I don’t know much about it, so any help is very much appreciated.
