Getting really sick of this crap (array referenced in a loop)

Why the hell does this code not work? It seems like every single time I go to code something with AS, it takes me forever, despite having used it for years, and for the last 4 months: full time. I am going :crazy:


var websiteURLs:Array = new Array();
websiteURLs = ["aboutUs.html", "services_main.html", "products_main.html", "contactUs.html", "undef", "undef", "undef", "undef", "undef", "undef"]
var k:Number = 0;
while(k<websiteURLs.length){    
    this["menu_"+k].onPress=function():Void{
        trace(websiteURLs[k]);
    }
    k++
}

I can put a number in for the array index and get a result, but putting in “k” yields “undefined”. I’ve written and re-written this code about 20 times now (thus the weird while loop). “menu+k” refers to buttons that are already instantiated.