Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
Neurox66
- Livecode Opensource Backer

- Posts: 120
- Joined: Tue May 22, 2012 1:57 pm
-
Contact:
Post
by Neurox66 » Fri Oct 05, 2012 11:01 pm
Hi,
in the background of my application the image change every 4 seconds .
If I stay in the same card, works well (Aren't exactly 4 seconds, but work.) If I go to another card and then return now start the problems, the pictures are running so syncopation and the image change every 1 or 2 seconds
Any hints?
my code:
Code: Select all
global gImmagine
on preOpenCard
put 1113 into gImmagine
end preOpenCard
on openCard
send "aggiornaSfondo2"
end openCard
on aggiornaSfondo2
put gImmagine + 1 into gImmagine
if gImmagine > 1118 then put 1113 into gImmagine
set the backgroundPattern of card "cHome" to gImmagine
send "aggiornaSfondo2" to me in 4 seconds
end aggiornaSfondo2
on closeCard
lock messages
repeat for each line 1 in the pendingMessages
answer the pendingMessages
cancel (item 1 of 1)
end repeat
unlock messages
end closeCard
Paolo Borzini | paolo@borzini.it
The WhiteFly Software | www.thewhitefly.it
Service on line for printers | www.4pellicole.it
-
bn
- VIP Livecode Opensource Backer

- Posts: 4172
- Joined: Sun Jan 07, 2007 9:12 pm
Post
by bn » Fri Oct 05, 2012 11:36 pm
Hi Neurox66,
try this
Code: Select all
on closeCard
repeat for each line aMessage in the pendingMessages
if aMessage contains "aggiornaSfondo2" then
cancel (item 1 of aMessage)
end if
end repeat
end closeCard
that should work
Kind regards
Bernd
-
Klaus
- Posts: 14198
- Joined: Sat Apr 08, 2006 8:41 am
-
Contact:
Post
by Klaus » Sat Oct 06, 2012 12:20 pm
Or even better like this
Note my comments!
Code: Select all
global gImmagine
LOCAL il_aggiornaSfondo2_messagio_id
## See below, what data this will hold
## I really like MEANINGFUL variable names ;-)
on preOpenCard
put 1113 into gImmagine
end preOpenCard
on openCard
## No need to SEND anything, since the handler is "know" in the card script, so just call it
aggiornaSfondo2
end openCard
on aggiornaSfondo2
put gImmagine + 1 into gImmagine
if gImmagine > 1118 then put 1113 into gImmagine
set the backgroundPattern of card "cHome" to gImmagine
## Every SEND will get an ID under which it is managed in Livecode
## So we store this ID in a local variable and can then later simply CANCEL that ID
## See the closecard handler
send "aggiornaSfondo2" to me in 4 seconds
put the RESULT into il_aggiornaSfondo2_messagio_id
end aggiornaSfondo2
## Please look up SEND in the dictionary!
on closeCard
cancel il_aggiornaSfondo2_messagio_id
## Done :-)
end closeCard
Best
Klaus
-
Neurox66
- Livecode Opensource Backer

- Posts: 120
- Joined: Tue May 22, 2012 1:57 pm
-
Contact:
Post
by Neurox66 » Sat Oct 06, 2012 4:32 pm
Ciao Bernd and Klaus,
Thanks for the clear full explanation.
Paolo
Paolo Borzini | paolo@borzini.it
The WhiteFly Software | www.thewhitefly.it
Service on line for printers | www.4pellicole.it