I am wondering if it is possible to create a closure in ActionScript2 like it is possible in Javascript.
This doesn't work:
var util = function(){
var init = function(){
trace(this + ': util'); // i want to know this thing works!
var myUtils = new MyAS2Utils(); // load some stuff
var url = myUtils.getURLInSomeReallyCoolWay(); // really, this is all fluff isn't it?
myAwesomeButton.onRelease = function(){
getURL(url,"_blank");
}
}
// and return the goods
return {
init : function(){
init();
}
}
}();
// now call the init funciton
util.init();
I have tried this other ways but it never works. I hope it's possible because if I'm forced to use AS2, I want to at least have a little fun with it :)
thanks!
aaron