krycek
11-08-2002, 01:25 PM
Coming in hot on the tail of the thread I had a few days ago about my mouse object, I think I have finally solved that problem - and raised a new one in order to properly solve it (new problem hence new thread :))
It boils down to this:
document.onmousedown = myobject.myfunction
I have managed to work out that, instead of CALLING the function myfunction from myobject each time the event fires, it seems to be actually copying the function, so that any 'this' references in the function apply to document and not myobject.
I have tried a number of methods of fixing this but unsuccessful so far. This is a real pain, because my mouse event handling script works perfectly except for that - and I need to introduce another function which checks the state of the mouse button being pressed - which is stored as a property of myobject.
Because of the nature of the script, I cannot use event.button, I have to firstly store the button value in myobject and then check that value later from another function. By the time it is checked, the event will have passed on.
Also, I cannot 'hard-code' the object's name, because I need to be able to rename it easily, and possibly create multiple instances.
Any help will be much appreciated :D
::] krycek [::
It boils down to this:
document.onmousedown = myobject.myfunction
I have managed to work out that, instead of CALLING the function myfunction from myobject each time the event fires, it seems to be actually copying the function, so that any 'this' references in the function apply to document and not myobject.
I have tried a number of methods of fixing this but unsuccessful so far. This is a real pain, because my mouse event handling script works perfectly except for that - and I need to introduce another function which checks the state of the mouse button being pressed - which is stored as a property of myobject.
Because of the nature of the script, I cannot use event.button, I have to firstly store the button value in myobject and then check that value later from another function. By the time it is checked, the event will have passed on.
Also, I cannot 'hard-code' the object's name, because I need to be able to rename it easily, and possibly create multiple instances.
Any help will be much appreciated :D
::] krycek [::