# Passing Variables on Photo Gallery

**URL:** <https://forum.kirupa.com/t/passing-variables-on-photo-gallery/208964>\
**Category:** flash\
**Created:** [December 4, 2006, 8:09pm UTC](https://forum.kirupa.com/t/passing-variables-on-photo-gallery/208964 "2006-12-04T20:09:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bradleykal](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/bradleykal/32/1447_2.png) [@bradleykal](https://forum.kirupa.com/u/bradleykal)\
**Post date:** [December 4, 2006, 8:09pm UTC](https://forum.kirupa.com/t/passing-variables-on-photo-gallery/208964/1 "2006-12-04T20:09:13Z")

</div>

ok, getting frustrated here.  
I’m trying to use a loop to set up the images + buttons I need for a photo gallery, however, I can’t seem to set variable for the image to load?! this should be easier…

> 

#include “lmc\_tween.as”  
/////////////  
var myButtons = [this.myButton\_1, this.myButton\_2, this.myButton\_3, this.myButton\_4, this.myButton\_5, this.myButton\_6];  
for (var i = 0; i\<myButtons.length; i++) {  
myButtons\*.originalY = myButtons\*.\_y;  
//toLoad = Number(i+1);  
//trace(toLoad);

```
var imageName = String("image_"+Number(i+1));
trace(imageName);
trace(myButtons*+"toload is "+imageName);
myButtons*._alpha = 0;
myButtons*.pict.loadMovie("images/homeGallery/thumbs/"+imageName+".jpg");
myButtons*.alphaTo(100, 5);
myButtons*.onRollOver = function() {
	this.tween("_y", this.originalY-5, 1);
	this.swapDepths(getNextHighestDepth());
};
myButtons*.onRollOut = myButtons*.onReleaseOutside=function () {
	this.tween("_y", this.originalY, 0.5);
	this.swapDepths(myDepth);
};
myButtons*.onRelease = function() {
	this._parent.activateItem(this);
	//this._parent.loadImage(this);
	// When tween is finished, take alpha to zero
	trace(imageName);
	photo_mc._alpha = 0;
	photo_mc.loadMovie("images/homeGallery/large/"+imageName+".jpg");
	photo_mc.alphaTo(100, 2);
};

```

}  
this.loadImage = function(item, toLoad) {  
trace(toLoad);  
};  
//////  
this.activateItem = function(item) {  
// Function that activates a button.  
// Checks if there’s an activated item already; if so, deactivates it.  
if (this.currentItem != false) {  
this.deActivateItem();  
}  
// Activates it, finally  
this.currentItem = item;  
this.currentItem.alphaTo(10, 1);  
// makes it ‘disabled’  
this.currentItem.enabled = false;  
// makes it a disabled button, so it won’t receive mouse events  
};  
this.deActivateItem = function() {  
// Deactivates the current activated menu item.  
this.currentItem.enabled = true;  
// back to a normal button/movieclip  
this.currentItem.alphaTo(100, 0.5);  
// back to its original opacity  
this.currentItem.tween(“\_y”, this.currentItem.originalY, 0.5);  
// back to its original position  
this.currentItem = undefined;  
};  
this.firstItem = function(item) {  
this.activateItem(item);  
//loadMovie(“movies/homepage/slide\_interior.swf”, pictureMC);  
};  
this.stop();  
/////////
