# Strange problem when trying to run a "tween" function from inside a class

**URL:** <https://forum.kirupa.com/t/strange-problem-when-trying-to-run-a-tween-function-from-inside-a-class/289057>\
**Category:** Uncategorized\
**Created:** [May 25, 2009, 8:47pm UTC](https://forum.kirupa.com/t/strange-problem-when-trying-to-run-a-tween-function-from-inside-a-class/289057 "2009-05-25T20:47:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![quicksmack](https://avatars.discourse-cdn.com/v4/letter/q/fbc32d/32.png) [@quicksmack](https://forum.kirupa.com/u/quicksmack)\
**Post date:** [May 25, 2009, 8:47pm UTC](https://forum.kirupa.com/t/strange-problem-when-trying-to-run-a-tween-function-from-inside-a-class/289057/1 "2009-05-25T20:47:40Z")

</div>

im trying to make a site navigation that does the following…  
1.) on mouse over, the navigation buttons’ alpha will become 0  
2.) a small movieclip with an instance name of “movingBar” should follow the X position of the current button being hovered over…

so i have created a custom class for all my buttons:  
[LEFT]

```auto
package
{
    import flash.display.MovieClip;
    import flash.events.MouseEvent;
    
    public class NavClass extends MovieClip
    {
        public function NavClass()
        {
            addEventListeners();
            this.buttonMode = true;
            this.useHandCursor = true;
        }
        
        public function addEventListeners():void
        {
            this.addEventListener(MouseEvent.MOUSE_OVER, followCursor)
            this.addEventListener(MouseEvent.MOUSE_OUT, removeNavGlow)
        }
        
        function followCursor(event:MouseEvent):void
        {
            this.alpha = 1;
            Object(root).updateBar();
        }

        function removeNavGlow(event:MouseEvent):void
        {
            this.alpha = 0;
        }
    }
}

```

[/LEFT]  
and on the main timeline, here’s the code:  
[LEFT]

```auto
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;

var moveBarTween:Tween;
var resizeBarTween:Tween;

function updateBar():void
{
    trace("code running");
    moveBarTween = new Tween(movingBar,"x",Regular.easeOut,movingBar.x,event.target.x,1,true);
    resizeBarTween = new Tween(movingBar,"width",None.easeNone,movingBar.width,event.target.width,1,true);
}

```

[/LEFT]  
if i try to publish the movie, the following error shows:  
“1120: Access of undefined property event.”

if i try to comment-out the other two statements like so:  
[LEFT]

```auto
function updateBar():void
{
    trace("code running");
    //moveBarTween = new Tween(movingBar,"x",Regular.easeOut,movingBar.x,event.target.x,1,true);
    //resizeBarTween = new Tween(movingBar,"width",None.easeNone,movingBar.width,event.target.width,1,true);
}

```

[/LEFT]  
the trace statement works and no errors are reported…

so it means theres some sort of problem with those two statements which i just cant figure out…
