# I think i have a problem with my Loop

**URL:** <https://forum.kirupa.com/t/i-think-i-have-a-problem-with-my-loop/321308>\
**Category:** flash\
**Created:** [April 16, 2011, 4:25am UTC](https://forum.kirupa.com/t/i-think-i-have-a-problem-with-my-loop/321308 "2011-04-16T04:25:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrTristan](https://avatars.discourse-cdn.com/v4/letter/m/bc8723/32.png) [@mrTristan](https://forum.kirupa.com/u/mrTristan)\
**Post date:** [April 16, 2011, 4:25am UTC](https://forum.kirupa.com/t/i-think-i-have-a-problem-with-my-loop/321308/1 "2011-04-16T04:25:04Z")

</div>

Hi guys,  
having some issues with converting an AS2 tutorial i found into AS3.

I have 4 Movieclips on stage, each called btn1, btn2, btn3 and btn4. Inside each movieclip is an image and then a layer above it called cover\_mc.

The piece of code i have here, which is located on the main timeline, should be registering a MOUSE\_OVER command and then fading out the cover\_mc movieclip from within that particular Movieclip im hovering over.

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

for (var i:Number=1; i<=4; i++) {
var current_btn = this["btn"+i];
current_btn.addEventListener(MouseEvent.MOUSE_OVER, btnOver);
function btnOver (e:MouseEvent):void{

var currentAlpha = this.cover_mc.alpha;
var transitionTween:Tween = new Tween(this.cover_mc, "alpha", Strong.easeOut, currentAlpha, 0, 0.5, true);
}
};

```

problem is this keeps bringing up the output:

```auto
TypeError: Error #1010: A term is undefined and has no properties.
    at Site_fla::MainTimeline/btnOver()

```

Seems like the lines …

```auto
for (var i:Number=1; i<=4; i++) {
 var current_btn = this["btn"+i];

```

arent doing their job properly. I added a trace (current\_btn); command after the MouseOver to trace out the current\_btn name i was moving over and it traced:

```auto
[object btn4_8]
 TypeError: Error #1010: A term is undefined and has no properties.
     at Site_fla::MainTimeline/btnOver()
 [object btn4_8]
 TypeError: Error #1010: A term is undefined and has no properties.
     at Site_fla::MainTimeline/btnOver()
 [object btn4_8]
 TypeError: Error #1010: A term is undefined and has no properties.
     at Site_fla::MainTimeline/btnOver()
 [object btn4_8]
 TypeError: Error #1010: A term is undefined and has no properties.
     at Site_fla::MainTimeline/btnOver()
 

```

It looks like the loop bit might be a bit screwed up as it keeps saying each button is ‘btn4\_8’ instead of just adding 1 to the button name each time

Then when i added the same trace command straight after the ‘var current\_btn’ code it was tracing:

```auto
[object btn1_2]
 [object btn2_4]
 [object btn3_6]
 [object btn4_8]

```

when it should have read ‘btn1, btn2 etc…’

Sorry for the massive post 😛  
Any ideas guys? its making me crazy  
thanks
