PDA

View Full Version : A little tricky loop question


AnubisTCP
05-23-2006, 03:25 AM
I may be going about this all wrong but here it it goes.

I'm trying to emulate a program that was done in flash. After a minute of inactivity this program will display an image and move it from upper left corner to lower right corner until the image has been clicked on. (Screen saver sorta thing) Now I can make the image move easily enough, however since it's in a loop nothing else can be done while the loop is going.


pg = Page.GetFocus();

while (pg == "Page1") do
min = 0; -- The number to start at
max = 100; -- The number to stop at
step = .1; -- The number to count by (in this case 0, 2, 4, ...)
for count = min, max, step do
Image.SetPos("Image1", 4 * count, 3 * count);
end
min = 0; -- The number to start at
max = 100; -- The number to stop at
step = -.1; -- The number to count by (in this case 0, 2, 4, ...)
for count = max, min, step do
Image.SetPos("Image1", 4 * count, 3 * count);
end
end



This code moves a 400x300 image from corner to corner in a 800x600 project. Any way to check for a mouse click on the image while in the loop? Or a better way to move the image(or any object)?

TIA

PS - Also to note, the image doesn't seem to move steadily as one would expect in an incremental loop. After about 2 secs in speeds up slightly, odd thats all.

yosik
05-23-2006, 08:23 AM
IMHO, what you should do is use the onTimer Event of the page.
Here is an example. Check code in the onShow Event, onTimer Event, Global Functions and onCLick Event of the image.

Hope that helps

Yossi

AnubisTCP
05-23-2006, 09:49 AM
Thanks yosik, will give it a try when I get back later.

AnubisTCP
05-23-2006, 03:05 PM
Think that might do the trick, will have to mess around with it.

yosik
05-23-2006, 04:09 PM
Good luck

Yossi