# AS3 ENTER\_FRAME glitch

**URL:** <https://forum.kirupa.com/t/as3-enter-frame-glitch/307405>\
**Category:** flash\
**Created:** [April 2, 2010, 6:32pm UTC](https://forum.kirupa.com/t/as3-enter-frame-glitch/307405 "2010-04-02T18:32:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![JamminBill](https://avatars.discourse-cdn.com/v4/letter/j/76d3ee/32.png) [@JamminBill](https://forum.kirupa.com/u/JamminBill)\
**Post date:** [April 2, 2010, 6:32pm UTC](https://forum.kirupa.com/t/as3-enter-frame-glitch/307405/1 "2010-04-02T18:32:06Z")

</div>

Ok, it’s probably not a glitch. I assume I’m doing something wrong. I’m doing a little practice animation (CS3) and I’m making the buttons grow on rollover and shrink back down on rollout. It works just fine except that if I move the mouse a little too fast the rollout doesn’t work and the button I just rolled out of stays large. Code below:

var aButtons:Array = new Array(mcBtn1, mcBtn2, mcBtn3, mcBtn4, mcBtn5, mcBtn6, mcBtn7, mcBtn8, mcBtn9, mcBtn10, mcBtn11, mcBtn12, mcBtn13, mcBtn14, mcBtn15);

for (var i:Number = 0; i\<aButtons.length; i++) {  
if (this.aButtons.length == this.aClips.length) {  
index = i;  
aButtons[index].i = index;  
trace(index);  
for (var j:Number = 0; j\<aClips.length; j++) {  
if (this.i == j) {  
trace(j);  
clipOpen(j);  
}  
}  
}  
}  
function clipOpen(num) {  
function rollOver(evt:Event):void {  
function buttonGrow(evt:Event):void {  
aButtons[num].width+=4;  
aButtons[num].height+=4;  
if (aButtons[num].width\>=45) {  
aButtons[num].removeEventListener(Event.ENTER\_FRAME,buttonGrow);  
}  
}  
aButtons[num].addEventListener(Event.ENTER\_FRAME,buttonGrow);  
}  
aButtons[num].addEventListener(MouseEvent.ROLL\_OVER,rollOver);  
function rollOut(evt:Event):void{  
function buttonShrink(evt:Event):void {  
aButtons[num].width-=4;  
aButtons[num].height-=4;  
if(aButtons[num].width\<=34.5){  
aButtons[num].removeEventListener(Event.ENTER\_FRAME,buttonShrink);  
}  
}  
aButtons[num].addEventListener(Event.ENTER\_FRAME,buttonShrink);  
}  
aButtons[num].addEventListener(MouseEvent.ROLL\_OUT,rollOut);  
}
