# Shape and sprite graphics

**URL:** <https://forum.kirupa.com/t/shape-and-sprite-graphics/297783>\
**Category:** Uncategorized\
**Created:** [October 8, 2009, 12:45pm UTC](https://forum.kirupa.com/t/shape-and-sprite-graphics/297783 "2009-10-08T12:45:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![regbolD](https://avatars.discourse-cdn.com/v4/letter/r/ecccb3/32.png) [@regbolD](https://forum.kirupa.com/u/regbolD)\
**Post date:** [October 8, 2009, 12:45pm UTC](https://forum.kirupa.com/t/shape-and-sprite-graphics/297783/1 "2009-10-08T12:45:53Z")

</div>

i am trying to receive in my function as a parameter either a shape or a sprite and then access their graphics property, but this gives me an error:

```auto

public static function makeRect( obj:DisplayObject, ...
            
var g:Graphics;
            
if(obj is Sprite){
    g = Sprite(obj).graphics;
}else{
    g = Shape(obj).graphics;
}
                
g.graphics.beginFill(_color, _alpha);
...

```

//1119: Access of possibly undefined property graphics through a reference with static type flash.display:Graphics.
