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:
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:
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);