I know I am doing something wrong but cant figure it out. I am trying to create a function that will allow me to set the x and y position in one line of code instead of having to write out the code everytime. I tried this:
var testBtn:mcTest = new mcTest();
testBtn.setPosition(100, 100);
function setPosition(xPos:Number, yPos:Number):void {
this.x = Math.round(xPos);
this.y = Math.round(yPos);
}
and Ive tried
function setPosition(xPos:Number, yPos:Number):void {
this.x = xPos;
this.y = yPos;
}
addChild(testBtn);
But I am getting an error:
TypeError: Error #1006: setPosition is not a function.
If anyone can help please let me know I have messed with this a few times and still cant get it to work. Thanks for any help on this topic.