# Newbie class problem

**URL:** <https://forum.kirupa.com/t/newbie-class-problem/252140>\
**Category:** Uncategorized\
**Created:** [February 16, 2008, 5:45pm UTC](https://forum.kirupa.com/t/newbie-class-problem/252140 "2008-02-16T17:45:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ranjeet\_naidu](https://avatars.discourse-cdn.com/v4/letter/r/59ef9b/32.png) [@ranjeet\_naidu](https://forum.kirupa.com/u/ranjeet_naidu)\
**Post date:** [February 16, 2008, 5:45pm UTC](https://forum.kirupa.com/t/newbie-class-problem/252140/1 "2008-02-16T17:45:59Z")

</div>

Hi there, i am trying to make a rollOver effect using class

```auto

package
{
    import flash.display.*;
    import flash.events.*;
    import flash.text.*;
    
    public class MainBtn extends MovieClip
    {
        
        public function MainBtn()
        {
            this.buttonMode = true;
            this.tbtnName.text = this.name;
            this.tbtnName.autoSize = TextFieldAutoSize.LEFT;
            //
            //this.MainBtn_bg.width = this.tbtnName.width+8;
            //
            this.addEventListener(MouseEvent.ROLL_OVER, btnRollOver);
            this.addEventListener(MouseEvent.ROLL_OUT, btnRollOut);
        }
        
        function btnRollOver(event:MouseEvent):void
        {
            trace("rollOver");
            event.target.gotoAndPlay(2);
        }
        
        function btnRollOut(event:MouseEvent):void
        {
            trace("rollOut");
            event.target.gotoAndPlay(11);
        }
        
    }
    
}

```

when i comment this part

```auto
this.MainBtn_bg.width = this.tbtnName.width+8;

```

then it works fine. Else it resizes the button but doesnt not have the rollOver effect. Please help.
