Hello :)
you can try 2 solutions :
1 - with a little property "index" to save the index value
var bt = this._targetMc["btnHldr" + i] ;
bt.index = i ;
bt.onPress = function()
{
trace("pressed: " + this.index);
}
2 - with Proxy method (like mx.utils.Delegate class but you can use
arguments :
// create Delegate Singleton
Delegate = {} ;
Delegate.create = function (scope, method:Function /*, arg1, arg2, ...,
argn*/):Function
{
var f:Function = function() {
var o = arguments.callee ;
var s = o.s ;
var m = o.m ;
var a = arguments.concat(o.a) ;
return m.apply(s, a) ;
} ;
f.s = scope ;
f.m = method ;
f.a = arguments.splice(2);
return f;
}
/// .... in your code
var press:Function = function (index:Number):Void
{
trace("pressed: " + index);
}
var writeBtnEvents:Function = function():Void
{
for (var i:Number = 0; i < 35; i++)
{
var bt = this._targetMc["btnHldr" + i] ;
bt.onPress = Delegate.create( this, press, i ) ;
}
}
EKA+ :)
2006/10/16, dnk <[EMAIL PROTECTED]>:
Hi there, I am trying to write a few mouse events for multiple
movieclips. Now say I have the following:
function writeBtnEvents() {
for (var i:Number = 0; i < 35; i++) {
this._targetMc["btnHldr" + i].onPress = function(i:Number) {
trace("pressed: " + i);
}
this._targetMc["btnHldr" + i].onRollOver = function(i:Number) {
trace("roll over" + i);
}
this._targetMc["btnHldr" + i].onRollOut = function() {
trace("roll off");
}
}
}
I read somewhere that you can not pass args to an onPress function, etc.
Is this true? Is there a better way to accomplish something like this?
d
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com