function setonrelease(subj,a){ subj.onRelease = function() { num=a; _root.action_man = a; } } for(....) setonrelease(eval("button"+j),j);