# Tweens and variables in instance names

**URL:** https://forum.kirupa.com/t/tweens-and-variables-in-instance-names/241866
**Category:** Uncategorized
**Created:** [October 18, 2007, 10:03pm UTC](https://forum.kirupa.com/t/tweens-and-variables-in-instance-names/241866 "2007-10-18T22:03:51Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![shawn57187](https://avatars.discourse-cdn.com/v4/letter/s/cc9497/32.png) [@shawn57187](https://forum.kirupa.com/u/shawn57187)
#### Post date: [October 18, 2007, 10:03pm UTC](https://forum.kirupa.com/t/tweens-and-variables-in-instance-names/241866/1 "2007-10-18T22:03:51Z")

</div>

So I have two questions that perhaps someone can help me with:

Q#1  
I am using the tween class to change the alpha value of a MC upon rollOver and rollOut. To refine the effect, I assigned a variable to the MC’s alpha value so if the mouse moves off the MC before it has reached 100% alpha, it wont start immediatly fading from 100%, but from the value it had reached before the user stopped the rollOver action. Unfortunately, when I leave my mouse over the MC until it goes to 100%, and then I wait a second or two, the alpha snaps back to 50% (the starting alpha value). I can’t figure out why this keeps happening, but I have run into it with other projects and I surmise it is the way I am using the tween class. Below is the code I used to make this happen.

To see the problem, here is a link to the compiled file:  
[http://www.shawnpiper.com/23hoyt/gallerytest.html](http://www.shawnpiper.com/23hoyt/gallerytest.html)

// image 1 Set 2  
groupA.group2.image1.onRelease = function() {  
loadMovie(“main\_resized/1.jpg”, pictureHolder);  
pictureHolder.\_xscale = 100;  
pictureHolder.\_yscale = 100;  
var alpha:Tween = new Tween(pictureHolder, “\_alpha”, Strong.easeOut, 0, 100, 5, true);  
};  
groupA.group2.image1.onRollOver = function () {  
var g:Number = groupA.group2.image1.\_alpha;  
var alphatween:Tween = new Tween(groupA.group2.image1, “\_alpha”, Strong.easeOut, g, 100, 1, true);  
}  
groupA.group2.image1.onRollOut = function () {  
var g:Number = groupA.group2.image1.\_alpha;  
var alphatween:Tween = new Tween(groupA.group2.image1, “\_alpha”, Strong.easeOut, g, 50, 8, true);  
}

Q#2  
Is there a way to loop through the instance names of similarly named movieclips? For instance, if I have 10 buttons with the instance name btn1 through btn9 and I want to change a certain property on all of them, is there a way I can substitute a variable for the number and use a for loop to cycle through them?

Thanks everyone :red:
