# ActionScript 2.0 - MovieClip Events as Class Functions

**URL:** <https://forum.kirupa.com/t/actionscript-2-0-movieclip-events-as-class-functions/195559>\
**Category:** flash\
**Created:** [August 1, 2006, 4:11pm UTC](https://forum.kirupa.com/t/actionscript-2-0-movieclip-events-as-class-functions/195559 "2006-08-01T16:11:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Case\_Sensitive](https://avatars.discourse-cdn.com/v4/letter/c/6bbea6/32.png) [@Case\_Sensitive](https://forum.kirupa.com/u/Case_Sensitive)\
**Post date:** [August 1, 2006, 4:11pm UTC](https://forum.kirupa.com/t/actionscript-2-0-movieclip-events-as-class-functions/195559/1 "2006-08-01T16:11:34Z")

</div>

Hi

I was wondering if you code help me out with Actionscript 2.0 and classes.

I have built a movie which has some nested movies within. I have created a class called ButtonMc in a .as file and used linkage to connect the symbol in the .FLA file with the class code in the ButtonMc.as file . This is the code for ButtonMc class:

```auto

class ButtonMc extends MovieClip
{
     //stores the MovieClip Instance which will be assigned to this class
     private var mcButton:MovieClip;
     
     /* Constructor - takes in the movieclip*/
     public function ButtonMc(mcInstance:MovieClip, mcInstanceName:String, mcInstanceDepth:Number, xPos:Number, yPos:Number)
     {
          //mcInstance will hold value "this"- which will mean a [COLOR=Black][COLOR=darkgreen][U]connection[/U][/COLOR][/COLOR][U][COLOR=Black] [/COLOR][/U]will be made 
          //between this objects (when created) movieclip property and the symbol in the .fla. 
          mcButton = mcInstance.attachMovie("ButtonMc", mcInstanceName, mcInstanceDepth);
          //set the initial position of movie on stage
          setPosition(xPos, yPos);
          //dont display the handcursor for this movie clip
          mcButton.useHandCursor = false;
          //starts the onrollover event
     }
     
     /* Sets/Changes the position of the movie clip on stage*/
     public function setPosition(x:Number, y:Number)
     {
          mcButton._x = x;
          mcButton._y = y;
     }
     
        /* when mouse rolls over */
     public function onRollOver()
     {
          mcButton.gotoAndPlay("over");
     }
     
}

```

Then on my \_root(main timeline) i have a action to create an instance of the the class and display the movie. I have this action:

```auto

var mc:ButtonMc = new ButtonMc(this, "mcunderstand", 0, 10, 50);

```

This movieclip displays when run, but nothing happens when i rollover the movieclip, it does not work and does not go to and play the specified frame for the “over” state.

Am i doing this wrong? I thought that all code related to an object would go inside the class and be ready to use?

Any help on this would be great

Thanks alot.
