How do I truncate a string, and keep the last value?

I have a bunch of thumbnails created by attachMovie.

Then when you click on one, I use “this” which returns me the complete mc path to this tumbnail icon.

I only want the last part which is a number. And sometimes it is more than one character.


newVar = this; (returns me the whole mc)

I want to extract the number “12” at the end, and set another variable equal to only the 12.

Does this make sense?


here’s a prototype that will parse backwards through a movie’s name, once it hits a non number character, it returns everything it’s parsed. if there are no non-number characters, the whole name is returned.

MovieClip.prototype.returnNum = function(){
	var s = this._name;
	var i = s.length
		if(isNaN(s.charAt(i))) break;
	return s.substr(i+1);