# .AS file Button difficulties

**URL:** <https://forum.kirupa.com/t/as-file-button-difficulties/283701>\
**Category:** flash\
**Created:** [March 10, 2009, 5:32am UTC](https://forum.kirupa.com/t/as-file-button-difficulties/283701 "2009-03-10T05:32:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kmanstudios](https://avatars.discourse-cdn.com/v4/letter/k/aeb1de/32.png) [@kmanstudios](https://forum.kirupa.com/u/kmanstudios)\
**Post date:** [March 10, 2009, 5:32am UTC](https://forum.kirupa.com/t/as-file-button-difficulties/283701/1 "2009-03-10T05:32:34Z")

</div>

[COLOR=#333333]Hello,

```
 I am new here. I am creating my website buttons and wanted to use a .AS file to control the mouse over and mouse out events for transparency. For some reason, it starts out as a lit button, but, once you roll over it, it then behaves as designed. To see the example, go to: http://www.kmanstudios.com/kmansite/

```

That is the test area for the site. I’m stumped. But, that’s not saying much really at this stage of my learning curve. When I used the base code on single buttons, it worked fine, but in the .AS file, it’s not quite right.  
Thanks in advance!!

Here is the .AS file code I used.

package  
{  
import flash.display.MovieClip;  
import fl.transitions.Tween;  
import fl.transitions.easing.\*;  
import flash.events.MouseEvent;

```
public class Button extends MovieClip

{
    
    public function Button()
    {
        buttonMode = true;
        this.addEventListener(MouseEvent.MOUSE_OVER, FadeIn);
        this.addEventListener(MouseEvent.MOUSE_OUT, FadeOut);
        
        
    }
    
    private function FadeIn(event:MouseEvent):void
    {
        var inTween:Tween
        this.removeEventListener(MouseEvent.MOUSE_OVER, FadeIn);
        this.addEventListener(MouseEvent.MOUSE_OUT, FadeIn);
        inTween = new Tween(this, "alpha", Strong.easeIn, 1, 0, 0.25, true);
        event.updateAfterEvent();
    }
    
    private function FadeOut(event:MouseEvent):void
    {
        var outTween:Tween
        this.removeEventListener(MouseEvent.MOUSE_OUT, FadeOut);
        this.addEventListener(MouseEvent.MOUSE_OVER, FadeOut);
        outTween = new Tween (this, "alpha", Strong.easeOut, 0, 1, 0.25, true);
        event.updateAfterEvent();
    }
}

```

}[/COLOR]
