Help with numerical values

This ActionScript is creating reading an XML file, and laying out thumbnail images. I’m stuck though! Each thumbnail is given a value of thumbnail[x], going from 0-5. **I wrote some mouse actions and need to access each thumbnail’s number, not entire name (where I have it in red below). **

“this” actually equals “thumbnails.thumbnail0”, “thumbnails.thumbnail1”, etc. But I need just the # on the end of that.

Can any AS guru’s out there help me?

myPhoto = new XML();
 myPhoto.ignoreWhite = true;
 myPhoto.onLoad = function(success) {
 	numimages = this.firstChild.childNodes.length;
 	spacing = 62;
 	for (i=0; i<numimages; i++) {
 		picHolder = this.firstChild.childNodes*;
 		thumbHolder = thumbnails.createEmptyMovieClip("thumbnail"+i, i);
 		thumbHolder._x = i*spacing;
 		thumbLoader = thumbholder.createEmptyMovieClip("thumbnail_image", 0);
 		thumbLoader.loadMovie(picHolder.attributes.thmb);
 		thumbHolder.title = picHolder.attributes.title;
 		thumbHolder.main = picHolder.attributes.main;
  
 		thumbHolder.onRelease = function() {
 			closeoutOver([color=Red]this[/color]);
 			loader.box.loadMovie(this.main);
 			over.over([color=Red]this[/color]).gotoAndStop(3);
 		};
 
 		thumbHolder.onRollover = function() {
 		if (over.over([color=Red]this[/color])._currentframe == 3) {
 			over.over([color=Red]this[/color]).stop();
 		}else{	
 			over.over([color=Red]this[/color]).gotoAndStop(2);
 		}
 		};
 
 		thumbHolder.onRollout = function() {
 		if (over.over([color=Red]this[/color])._currentframe == 3) {
 			over.over([color=Red]this[/color]).stop();
 		}else{	
 			over.over([color=Red]this[/color]).gotoAndStop(1);
 		}
 		};
 }
 
 }

hi,

I haven’t look at all of your code… so I’m not sure if this is it. If it isn’t, you should be able to get the idea:


for (i = 0; i < numimages; i++) {
	picHolder = this.firstChild.childNodes*;
	thumbHolder = thumbnails.createEmptyMovieClip("thumbnail" + i, i);
	// store the variable i in each movie clip
	thumbHolder.i = i;
	// more of your code here...
	thumbHolder.onRelease = function()
	{
		// you can call the interger you wish with this.i
		trace(this.i);
		// more of your code here...
	};
}

thanks numomira! It works, except I can’t the following to work:

thumbHolder.onRollover = function() {
 trace(over("over"+this.i).hello);
 };

I want it to return “over.over0.hello” with the value of this.i in the 2nd occurance of the word “over”. I probably have the syntax wrong.

Can anyone help?

Square brackets:


thumbHolder.onRollover = function() {
 trace(over["over"+this.i].hello);
 };

Read dynamic references for more details.