# Bug? exception thrown by getter - BitmapData

**URL:** <https://forum.kirupa.com/t/bug-exception-thrown-by-getter-bitmapdata/318241>\
**Category:** Uncategorized\
**Created:** [January 14, 2011, 5:56am UTC](https://forum.kirupa.com/t/bug-exception-thrown-by-getter-bitmapdata/318241 "2011-01-14T05:56:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jwopitz](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/jwopitz/32/1556_2.png) [@jwopitz](https://forum.kirupa.com/u/jwopitz)\
**Post date:** [January 14, 2011, 5:56am UTC](https://forum.kirupa.com/t/bug-exception-thrown-by-getter-bitmapdata/318241/1 "2011-01-14T05:56:08Z")

</div>

Interesting little issue I am having here.

Basically I have a method that gets called on ENTER\_FRAME. I have some vars that are getting accessed each time and so to save on fetching from the related object, when I set the related object during initialization I simple set the vars to those props on the related object. Here is some code to help visualize:

```auto
private var canvas:BitmapData;

private var _relatedObject:SomeClass;

public function set relatedObject (value:SomeClass):void
{
    _relatedObject = value;
    if (_relatedObject)
         canvas = _relatedObject.canvas;
}

private function onEnterFrameHandler ():void
{
    /*
    //this works no problem
    canvas = _relatedObject.canvas;
    */

    /*
    by itself this barfs and says
    ArgumentError: Error #2015: Invalid BitmapData.
	atflash.display::BitmapData/get width()
	atflash.display::BitmapData/get rect()
    */
    canvas.fillRect(canvas.rect, 0x00FF00FF);
}

```

Inspecting via the debugger I can easily see that it is having issues seeing the local vars props, but it can inspect the \_relatedObject.canvas props no problem.

Anyone have a hint?
