# How do I simplify this code? (alpha change all buttons on rollover)

**URL:** <https://forum.kirupa.com/t/how-do-i-simplify-this-code-alpha-change-all-buttons-on-rollover/302885>\
**Category:** Uncategorized\
**Created:** [January 9, 2010, 7:43am UTC](https://forum.kirupa.com/t/how-do-i-simplify-this-code-alpha-change-all-buttons-on-rollover/302885 "2010-01-09T07:43:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![emeyer](https://avatars.discourse-cdn.com/v4/letter/e/b5a626/32.png) [@emeyer](https://forum.kirupa.com/u/emeyer)\
**Post date:** [January 9, 2010, 7:43am UTC](https://forum.kirupa.com/t/how-do-i-simplify-this-code-alpha-change-all-buttons-on-rollover/302885/1 "2010-01-09T07:43:47Z")

</div>

Hi all. I have a bunch of thumbnails which I want to be treated the same on rollover/rollout/press. Right now, I have it working so that the alpha changes on all of them on rollover/rollout/press, but to do that, I have a code for each individual thumbnail, and I know there has to be a way to just have one code that applies to all of them instead of repeating so much (but I’m just not sure how to do it).

This is what I have right now:

```auto
function over() {
this._alpha=100;
}

function down() {
this._alpha=50;
}

function out() {
this._alpha=60;
}

thumb_001.onRollOver = over;
thumb_001.onPress = down;
thumb_001.onRollOut = out;
thumb_001.onRelease = function () {
	getURL("javascript:window.open('gallery/001.jpg','win_name','width=450,height=675,resizable=yes,scrollbars=yes,top='+((screen.availHeight/2)-(675/2))+',left='+((screen.availWidth/2)-(450/2))+'');void(0);");

}

thumb_002.onRollOver = over;
thumb_002.onPress = down;
thumb_002.onRollOut = out;
thumb_002.onRelease = function () {
	getURL("javascript:window.open('gallery/002.jpg','win_name','width=450,height=675,resizable=yes,scrollbars=yes,top='+((screen.availHeight/2)-(675/2))+',left='+((screen.availWidth/2)-(450/2))+'');void(0);");

}

thumb_003.onRollOver = over;
thumb_003.onPress = down;
thumb_003.onRollOut = out;
thumb_003.onRelease = onRelease = function () {
	getURL("javascript:window.open('gallery/003.jpg','win_name','width=675,height=450,resizable=yes,scrollbars=yes,top='+((screen.availHeight/2)-(450/2))+',left='+((screen.availWidth/2)-(675/2))+'');void(0);");

}

thumb_004.onRollOver = over;
thumb_004.onPress = down;
thumb_004.onRollOut = out;
thumb_004.onRelease = onRelease = function () {
	getURL("javascript:window.open('gallery/004.jpg','win_name','width=450,height=675,resizable=yes,scrollbars=yes,top='+((screen.availHeight/2)-(675/2))+',left='+((screen.availWidth/2)-(450/2))+'');void(0);");

}

thumb_005.onRollOver = over;
thumb_005.onPress = down;
thumb_005.onRollOut = out;
thumb_005.onRelease = onRelease = function () {
	getURL("javascript:window.open('gallery/005.jpg','win_name','width=675,height=450,resizable=yes,scrollbars=yes,top='+((screen.availHeight/2)-(450/2))+',left='+((screen.availWidth/2)-(675/2))+'');void(0);");

}

thumb_006.onRollOver = over;
thumb_006.onPress = down;
thumb_006.onRollOut = out;
thumb_006.onRelease = onRelease = function () {
	getURL("javascript:window.open('gallery/006.jpg','win_name','width=675,height=482,resizable=yes,scrollbars=yes,top='+((screen.availHeight/2)-(482/2))+',left='+((screen.availWidth/2)-(675/2))+'');void(0);");

}

thumb_007.onRollOver = over;
thumb_007.onPress = down;
thumb_007.onRollOut = out;
thumb_007.onRelease = onRelease = function () {
	getURL("javascript:window.open('gallery/007.jpg','win_name','width=675,height=482,resizable=yes,scrollbars=yes,top='+((screen.availHeight/2)-(482/2))+',left='+((screen.availWidth/2)-(675/2))+'');void(0);");

}

thumb_008.onRollOver = over;
thumb_008.onPress = down;
thumb_008.onRollOut = out;
thumb_008.onRelease = onRelease = function () {
	getURL("javascript:window.open('gallery/008.jpg','win_name','width=482,height=675,resizable=yes,scrollbars=yes,top='+((screen.availHeight/2)-(675/2))+',left='+((screen.availWidth/2)-(482/2))+'');void(0);");

}

thumb_009.onRollOver = over;
thumb_009.onPress = down;
thumb_009.onRollOut = out;
thumb_009.onRelease = onRelease = function () {
	getURL("javascript:window.open('gallery/009.jpg','win_name','width=675,height=588,resizable=yes,scrollbars=yes,top='+((screen.availHeight/2)-(588/2))+',left='+((screen.availWidth/2)-(675/2))+'');void(0);");

}

thumb_010.onRollOver = over;
thumb_010.onPress = down;
thumb_010.onRollOut = out;
thumb_010.onRelease = onRelease = function () {
	getURL("javascript:window.open('gallery/010.jpg','win_name','width=675,height=506,resizable=yes,scrollbars=yes,top='+((screen.availHeight/2)-(506/2))+',left='+((screen.availWidth/2)-(675/2))+'');void(0);");

}

thumb_011.onRollOver = over;
thumb_011.onPress = down;
thumb_011.onRollOut = out;
thumb_011.onRelease = onRelease = function () {
	getURL("javascript:window.open('gallery/011.jpg','win_name','width=436,height=675,resizable=yes,scrollbars=yes,top='+((screen.availHeight/2)-(675/2))+',left='+((screen.availWidth/2)-(436/2))+'');void(0);");

}

thumb_012.onRollOver = over;
thumb_012.onPress = down;
thumb_012.onRollOut = out;
thumb_012.onRelease = onRelease = function () {
	getURL("javascript:window.open('gallery/012.jpg','win_name','width=506,height=675,resizable=yes,scrollbars=yes,top='+((screen.availHeight/2)-(675/2))+',left='+((screen.availWidth/2)-(506/2))+'');void(0);");

}

```

But for like 50 pictures. So it’s a little impractical, and I was just thinking that if I can find a way to do this without repeating the same code over and over that would probably be better, but I just don’t know how to do it (I’m a designer/animator, but not a strong actionscripter).

Any help as to how to do this would be very much appreciated!
