Page 1 of 1

changing images on a card

Posted: Tue Sep 08, 2009 5:49 am
by mickus
Hi All,

I am completely new to programming and need to get an application up and running in a few weeks. I need an image to change every few seconds to another image and so on. Does anyone know how I can set this up, or what steps I need to go through??

Any help would be much appreciated!

Posted: Tue Sep 08, 2009 9:00 am
by Mark
Dear Mickus,

As a start, create a folder with a bunch of small pictures and try the following in a checkbox button. For now, please make sure that the folder only contains pictures that Revolution can read.

Code: Select all

on mouseUp
  if the hilite of me then
    answer folder "Select a folder with pictures files only"
    if it is not empty then
      set the defaultFolder to it
      showPict
    end if
  else
    put the pendingMessages into myMessages
    filter myMessages with "showPict"
    repeat for each line myLine in myMessages
      cancel item 1 of myLine
    end repeat
  end if
end mouseUp

on showPict
  put any line of the files into myFile
  set the filename of img 1 to myFile
  if the hilite of me then send showPict to me in 5 secs
end showPict
Make sure to save the stack before you click the button. I didn't test this code, please mind typos. Let me know how it goes.

Best,

Mark

Posted: Tue Sep 08, 2009 11:12 am
by mickus
Hi Mark,

Thanks heaps for your response. I have tried it, and when I click the button it opens the file on my desktop so that I can then select from the pics in the file. Do you know how I can make it so that an image appears, and then after a second it changes to another image and then another etc?. Sorry, but am finding it hard to grasp all the scripting language!

Posted: Tue Sep 08, 2009 12:08 pm
by Mark
Dear mickus,

That's exactly what the script does. Perhaps you should read my previous message again and give it another try.

Best,

Mark

Posted: Tue Sep 08, 2009 12:12 pm
by SparkOut
Make sure you have an image area on your card which can display the image that you populate the filename with in the showPict handler.

Otherwise, make sure that you don't repeatedly click the checkbox, or it will turn off the display!

Oh, and the dialogue box is just for you to select the folder containing the images - you don't select any image files inside that folder. Just use that dialogue to let rev know where the images are kept and it will use that location for the rest of the automatic display.

Posted: Wed Sep 09, 2009 4:47 am
by mickus
I didn't have an image box displayed on the card for the images to be visible in - thanks for the heads up SparkOut.

Thanks again for the script Mark - I have tried it again and it works well, however before it starts displaying the images, it comes up with a box asking me to choose the file from those listed on my desktop. Do you know how I can eliminate that part of the process?

Posted: Wed Sep 09, 2009 9:17 am
by SparkOut
You somehow have to let Rev know where to find the images to display. Mark's dialogue was just to make that easy for you to practice using the handler to display a random image from the collection at specified interval.
If you know for certain that the images will always be in a particular folder then you can script that line directly, as in

Code: Select all

set the default folder to "<the fixed path where the images are kept>"
but if you install on different machines you might have a problem where the installation on some machines is not in the same place as other machines. You could use relative file paths to make sure that the folder where the images are kept is always a subdirectory of the one where the application is executed. You need to look up in the docs (the Revolution dictionary) for defaultFolder and read about the way to reference file paths.