var opacVal = 0.9;
$('someImage').addEvent('mousemove',
function(element, opacVal){
element.set({'opacity': opacVal});
}.bind( this, [$('someImage'), opacVal])
);
However, there is a problem with above approach. Since, we have forcefully bound the parameters of the function, therefore, the event object is not passed to the function. If you want to pass the event object aswell, then use the bindWithEvent function of mootools. Consider the following code;
var opacVal = 0.9;
$('someImage').addEvent('mousemove',
function(element, opacVal){
element.set({'opacity': opacVal});
event.stop();
}.bindWithEvent( this, [$('someImage'), opacVal])
);
No comments:
Post a Comment