mx.utils.Delegate class does not take into account any passed variables, there is no third argument in the create method of the class and so it will be ignored.
Instead of delegating the scope of the button events to that of the class, you could just pass a reference to the scope of the class object and use that variable to access the class objects methods and properties from the scope of the buttons. That would probably be how most people would handle it.
However, there is a trick you can do so you can write your own version of the Delegate class that will pass any number of arguments which might save you reworking what you already have...
so you could assign the event functions to this if you wanted...Code:class lexicon.utils.Delegate extends Object { static function create(obj:Object, func:Function):Function { var f = function() { var target = arguments.callee.target; var func = arguments.callee.func; var args = arguments.callee.args; return func.apply(target, arguments.concat(args)); }; f.target = obj; f.func = func; f.args = (arguments.length>2) ? arguments.slice(2) : []; return f; } function Delegate(f:Function) { func = f; } private var func:Function; function createDelegate(obj:Object):Function { return create(obj, func); } }
and access the passed vars in your setButtons function...Code:lexicon.utils.Delegate.create(this, setButtons, i, buttonContainer_mc);
Code:function setButtons(i:Number, mc:MovieClip):Void { mc._alpha = 100; trace("IDENT"+buttonContainer_mc.thisSelected_mc._alpha); trace("I IS:"+ i); //current_track_number = i; //stopmusic(); //playmusic(); }




Reply With Quote