# Help Graphics.prototype?

**URL:** <https://forum.kirupa.com/t/help-graphics-prototype/282231>\
**Category:** flash\
**Created:** [February 19, 2009, 6:26am UTC](https://forum.kirupa.com/t/help-graphics-prototype/282231 "2009-02-19T06:26:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![syepes](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@syepes](https://forum.kirupa.com/u/syepes)\
**Post date:** [February 19, 2009, 6:26am UTC](https://forum.kirupa.com/t/help-graphics-prototype/282231/1 "2009-02-19T06:26:40Z")

</div>

Hi all,

Sorry for the newbie question.  
I need to add a global method to the Sprite Class, for example “pos” but just cant get it to work.

Anyone know what i am doing wrong?

This works with MovieClips, but i need this to work with Stripte objects to:

```auto
DisplayObject.prototype.pos = function(x:int, y:int, w:int, h:int):void {
  this.x = x;
  this.y = y;
  this.width = w;
  this.height = h;
};

var header:Sprite = addChild(new MovieClip()) as MovieClip;
drawBox(header,0,0, stage.stageWidth, 90, 0x333333, 1, 2, 0x000000, 1);
..
header.pos(20, 20, 50, 100);

```

But this does not work:

```auto
import flash.display.Graphics;
Graphics.prototype.pos = function(x:int, y:int, w:int, h:int):void {
  this.x = x;
  this.y = y;
  this.width = w;
  this.height = h;
};

var header:Sprite = addChild(new Sprite()) as Sprite;
drawBox(header,0,0, stage.stageWidth, 90, 0x333333, 1, 2, 0x000000, 1);
..
header.graphics.pos(20, 20, 50, 100);

```
