Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Call function every second
Started by conti.edo Jan 16 2014 12:58 PM

- - - - -
5 replies to this topic
function interval calling second
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

conti.edo

[GLOBAL: userInfoPane.html]
conti.edo
  • Observer

  • 8 posts
  • Corona SDK

How can I call a function every second?
I would need to make a call HttpRequest, and the information must be updated, so I need a way to summon a function every second.

How can I do?

Thank you.

 



[TOPIC: post.html]
#2

eja

[GLOBAL: userInfoPane.html]
eja
  • Contributor

  • 124 posts
  • Enterprise

How can I call a function every second?
I would need to make a call HttpRequest, and the information must be updated, so I need a way to summon a function every second.

How can I do?

Thank you.


local function yourFunction()
  --do your thang
end
 

Runtime:addEventListener("enterFrame",yourFunction)



[TOPIC: post.html]
#3

dchan

[GLOBAL: userInfoPane.html]
dchan
  • Contributor

  • 360 posts
  • Corona Staff

http://docs.coronalabs.com/daily/api/library/timer/performWithDelay.html

 

enterFrame would happen much more often than once a second.



[TOPIC: post.html]
#4

eja

[GLOBAL: userInfoPane.html]
eja
  • Contributor

  • 124 posts
  • Enterprise

http://docs.coronalabs.com/daily/api/library/timer/performWithDelay.html

 

enterFrame would happen much more often than once a second.

 

lmao so true, I just realized what i wrote and yeah 30 to 60 times faster



[TOPIC: post.html]
#5

conti.edo

[GLOBAL: userInfoPane.html]
conti.edo
  • Observer

  • 8 posts
  • Corona SDK

http://docs.coronalabs.com/daily/api/library/timer/performWithDelay.html

 

enterFrame would happen much more often than once a second.

 

Do you mean like this?

 

timer.performWithDelay(1000, function, 0)
 

 

Every second function is called in an infinite loop, right?



[TOPIC: post.html]
#6

dchan

[GLOBAL: userInfoPane.html]
dchan
  • Contributor

  • 360 posts
  • Corona Staff


[topic_controls]
[/topic_controls]