Jump to content

setTimer is doing weird


Puma

Recommended Posts

This works:

    setTimer(function () removeEventHandler("onClientRender", getRootElement(), clientRenderLogo) end, 5000, 1) 

This doesn't:

    setTimer(removeEventHandler, 5000, 1, "onClientRender", getRootElement(), clientRenderLogo) 

Why doesn't the second way work?

Link to comment
This works:
    setTimer(function () removeEventHandler("onClientRender", getRootElement(), clientRenderLogo) end, 5000, 1) 

This doesn't:

    setTimer(removeEventHandler, 5000, 1, "onClientRender", getRootElement(), clientRenderLogo) 

Why doesn't the second way work?

i think that the 1° works just because the timer need the

function () ....... end 

and you can't insert just

removeEventHandler 

but you must connect a function writed by you, not a function like

removeEventHandler 

.

Link to comment

setTimer needs the function and it's all fine about that. function() ... end is a function definition, while removeEventHandler is a variable which holds the function. I see where the real problem may be. If the function clientRenderLogo is defined after the timer is created, then it means that nil value was used as a parameter for removeEventHandler. So you need to move setTimer after the function definition. But if it's already done in this way, I don't know what is the problem.

Link to comment
setTimer needs the function and it's all fine about that. function() ... end is a function definition, while removeEventHandler is a variable which holds the function. I see where the real problem may be. If the function clientRenderLogo is defined after the timer is created, then it means that nil value was used as a parameter for removeEventHandler. So you need to move setTimer after the function definition. But if it's already done in this way, I don't know what is the problem.

i meant that :D

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...