When you do:
>> this["clip"+j]["button"+j].onRollOver = function() {
You are assigning the clip's onRollOver even to an anonymous function.
So the variable "j" is not known inside the function. To overcome this,
it is recommended you do not use anonymous functions, but use (and I
assume you are in the AS1/2 world, not AS3) delegate to assign events to
functions:
this["clip"+j]["button"+j].onRollOver = mx.utils.Delegate.create(this,
doRollOver);
To bring the variable "j" along with it, one way is to assign an object
and then tag it on:
var del:Object = this["clip"+j]["button"+j].onRollOver =
mx.utils.Delegate.create(this, doRollOver);
del.id = j;
function doRollOver()
{
trace(arguments.caller.id)//value of "j"
}
or, still use an anonymous function (yuck) and assign it as a property
of the button directly:
this["clip"+j]["button"+j].id = j
this["clip"+j]["button"+j].onRollOver = function(){
trace(this.id)//value of "j"
}
Jason Merrill
Bank of America
GT&O L&LD Solutions Design & Development
eTools & Multimedia
Bank of America Flash Platform Developer Community
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders