# Extending the TextField class

**URL:** https://forum.kirupa.com/t/extending-the-textfield-class/322604
**Category:** flash
**Created:** [May 26, 2011, 8:42pm UTC](https://forum.kirupa.com/t/extending-the-textfield-class/322604 "2011-05-26T20:42:22Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![JackC](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@JackC](https://forum.kirupa.com/u/JackC)
#### Post date: [May 26, 2011, 8:42pm UTC](https://forum.kirupa.com/t/extending-the-textfield-class/322604/1 "2011-05-26T20:42:22Z")

</div>

Hey guys,  
This is my first post on Kirupa.

Basically the issue I am having is related to the TextField class. I was hoping to create a custom textField class which would allow me to specify the x and y positions of the textField upon creating it.

However in trying I received numerous errors. Below is my code.

AS file

```auto
package
{
    import flash.text.TextField;
    
    public class TextBox extends TextField
    {
        //variables
        var textBox:TextField = new TextField();
        var xPosition:Number;
        var yPosition:Number;
        
        
        public function TextBox(xPos:Number, yPos:Number)
        {
            textBox.xPosition = xPos;
            textBox.yPosition = yPos;
        }
        
        
        public function setXPosition(xPos:Number):void
        {
            textBox.xPosition = xPos;
        
        }
        
    }
}

```

FLA file

```auto
var tb:TextBox = new TextBox(30, 30);

```

When I run I get this error…

1119: Access of possibly undefined property xPosition through a reference with static type flash.text:TextField.

I would appriciate any help on the matter, Im new to the whole concept of OOP.

Regards,  
jack
