Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Repeat loop, plays too fast?

Status
Not open for further replies.

styleBunny

Technical User
Jun 20, 2002
133
0
0
AU
I folks,

i am using a repeat loop to fade / fade out image, but i want to controll the speed of the transition, the repeat loops so quickly, i fear it might lag on some older systems. Even if thats not the case i would like the fade in / out to be a little slower over all..

repeat with n = 1 to 100
sprite(2).blend = n
sprite(1).blend = (100-n)
updateStage
end repeat

is there a way to use the pause or wait functions? Or even a way to use a property description list box thingy?

Cheers
Paul.
 
You cannot control the speed of Lingo execution. Director tries to run the script as quick as possible, of course.

Director cannot execute more than one script at a time. When "repeat" loop starts it doesn't do anything else. This means your script of counting 1 to 100 would take a millisecond or two for Director. You won't see the fading effects unless you have very fast eyes!

Instead of repeat loop, use "enterFrame". Attach this behaviour to the sprite:
--
on enterFrame me
sprite(me.spriteNum).blend = sprite(me.spriteNum).blend - 1
end enterFrame
--
 
Hi Kenneth,

thanks again, i had suspected as much :(. i created a similar script which worked on exitframe, like you suggested on enterframe, i tried to get clever and use a loop this time, but looks like i will have go back one step.

I spose loops still handy for sorting or matching.

thanks again,
Paul.
 
You can also use timeout object. This may be better for your purpose as you can control fade timing easily. In this example the timeout occurs every 50 milliseconds but you can speed up/slow down by changing the figure.

-- (frame script)
property pBlend

on beginSprite me
pBlend = 0
new timeOut("fadeTimer", 50, #fadeHandler, me)
end beginSprite

on fadeHandler
pBlend = pBlend + 1
sprite(1).blend = 100 - pBlend
sprite(2).blend = pBlend
if pBlend = 100 then timeout("fadeTimer").forget()
end fadeHandler

on exitFrame me
go the frame
end exitFrame
--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top