I know this has to be an issue of global vs local variables, but i can't figure out what I need to do here.

I wrote a function called "zeros" to create a catalog system that starts with 001 and ends with 999. When I run the script, it has an output screen that pops up to show me that the right numbers are being returned, but the problem is that when gets to the part where an email pops up, it returns "undefined" where it should return the number that is being shown on the output screen.

Here is the part of the script that I'm working with:

_root.attachMovie("image"+this.largerImage,"large_ mc",2);
var b = this.largerImage;
function zeros(n) {
if (n<10 && n>=0) {
n = "00"+n;
else if (a<100 && a>=10) {
n = "0"+n;
return n;
mybutton1.onPress = function(){
getURL("mailto:?subject=Check out this design!"+"&body="+"Visit http://www.TamRonJewelry.com/ladiesrings.hml and click on "+n+"!");

I'm kinda new to action script. Can anyone help me figure out why this is happening? I tried putting the function inside the mybutton1 function, and the same result.