...

View Full Version : Need a cutting edge solution to an identified problem!



Sleeping_Troll
05-29-2009, 02:55 AM
I have a script that runs continuously, It has a setInterval to run a function called moveOrbs. Problem is I want to use an event observer... but an event observer will not trigger until javascript finishes... and this one never does...

Solution, I believe (hope actually) there must be some background event going on in the browser that occurs regularly, I could use that event to trigger my moveOrbs function, and thus allow javascript to stop for several milliseconds, does anyone know of such a background event?

Old Pedant
05-29-2009, 03:25 AM
Scratching my head.

A function run by way of setInterval( ) *DOES* finish, assuming it doesn't have some infinite loop in it (but then you'd have bigger problems than this). And the thread is released.

Witness the fact that you can have two or more setInterval( ) based function calls running at the same time.

So why doesn't the event observer get a chance to run in between calls???

What kind of event observer, specifically?

Old Pedant
05-29-2009, 03:35 AM
I assume this is same problem as prior thread?

I went to http://huduzu.trollnest.com and there is nothing on the page except the little form at the top right. This in FF 3.

In MSIE 6, I get the little blocks floating around, but I get tons of JavaScript errors, then.

For example, I get "Orb[i] is not an object in this code:


Event.observe(
'Orb'+i,
'mouseover',
function(event) {
Orb[i].static=1;
alert("hello");
});

Dare I assume that the code is only intended to run in a particular browser?? Neither FF3 nor MSIE6?

Sleeping_Troll
05-29-2009, 04:11 AM
Yes, I was playing with it, and no javascript does not 'finish' on setInterval or setTimeout, it simply sets a timer to interupt it. If it finishes everything else it will idle until the timer is finished, it is almost like the timer is a seperate thread, but of course we know javascript is single threaded. I have uploaded a version that will run in slow motion and you will see how much time there is to service the event if indeed javascript had stopped. I wish (and still hold out hope) that I were incorrect. The problem with firefox is that it reports a registry undefined error from the prototype script for the mouseover event. If you have prototype and look at the line number indicated you will see that this is where the syntax differences for IE and firefox are supposed to be resolved.

Thanks for your interest by the way!

Old Pedant
05-29-2009, 04:17 AM
Do you know why it does nothing at all in FF3??

I do *NOT* see the <DIV> (or whatever it is) where the floating squares appear in MSIE 6.

But it looks to me like the event observer *IS* working in MSIE 6, because ineed it gets the error *IN THE OBSERVER*!

What browser are you running??

Sleeping_Troll
05-29-2009, 04:51 AM
It does not wprk in ff because prototype is not registering the observer, that is a problem I can tackle later. I am running IE8 and FF3, IE6 has a ton of problems with images and alpha transparency, I don't even try to support it anymore. Yes it is registering in IE, it just never gets a chance to handle it. Try resizing your window very small, it will cause the script to crash and then the observer will be able to service.
I will put an alert in the handler.

Old Pedant
05-29-2009, 07:53 AM
Sorry...it now at least shows in FF3. I assume you went ahead and made the change you said you needed.

But resizing FF3 window as small as I can does *NOT* cause a crash. No alerts coming from observer, etc.

And in MSIE 6 I get an error in a completely different place than before, but *still* I get it as a result of the mouseover observer. Unless I'm mistaken, that means the observer *IS* working, no??

I can't look at it more tonight. I don't have MSIE 8 yet, on purpose, but I could look at it with MSIE 7, if there is any point.

I doubt I'm going to be any help, unfortunately. I can see this would take some time to try to repro certain behaviors, and I just don't have it right now.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum