1 Reply Latest reply on Jul 4, 2007 10:20 PM by wgb14

    Display a series of pictures on the stage based on the value of a variable

    wgb14 Level 1
      Hi all,

      Here is another interesting problem! Well, I have an interactive retention test that loads questions from an xml file based on the value of a scenario variable (e.g., if scenario = Architecture then load Q_set 1, if scenario = History then load something else). Now, I would like to extent this and display a series of pictures on my stage that will be valid only in the current scenario. Here is my code so far. I was thinking to load some image list on the start of the movie (e.g., Architecture_list, History_list) and then call them based on the value of the scenario variable, but i would also like to hear what you have to say. Any ideas?
        • 1. Re: Display a series of pictures on the stage based on the value of a variable
          wgb14 Level 1
          The answer is a series of handlers: One called at the beginning of the movie to fill in the lists from the proper folders (based on the value of the gimage variable) and the others called on next and previous. Here they are in case yu need them:


          ---------
          global gFileList,gImagePath,gimages

          on buildList

          gFileList = []

          -- defining path to images:

          gImagePath = "@images/"&gimages&"/"

          repeat with i = 1 to the maxinteger
          thisFile = getNthFileNameInFolder(gImagePath, i)
          if thisFile = EMPTY then exit repeat
          if thisFile = the movie then next repeat
          fileTypes = [".bmp", ".pct", ".jpg", ".gif"]
          howManyTypes = count(fileTypes)
          repeat with thisType = 1 to howManyTypes
          extension = getAt(fileTypes, thisType)
          if thisFile contains extension then
          gFileList.append(thisFile)
          end if
          end repeat
          end repeat

          member("display").filename = gImagePath & gFileList[1] -- put the first picture of the folder to the proper place

          member("display").picture = member ("display").picture

          end buildList

          --------------------
          global gFileList, gFileIndex,gImagePath

          on nextFile

          gFileIndex = gFileIndex + 1

          if gFileIndex > count(gFileList) then

          whichFile = gFileList[1] --set the image holder = to the last image loaded
          gFileIndex = 1 -- set the index to the last loaded question

          member("display").filename = gImagePath & whichFile
          member("display").picture = member ("display").picture
          updateStage

          -- go to the audio questions

          _movie.go(31)

          else

          whichFile = gFileList.getAt(gFileIndex)

          member("display").filename = gImagePath & whichFile

          member("display").picture = member ("display").picture

          updateStage
          end if

          end

          global gFileList,gFileIndex,gImagePath
          -----------------------------------------------------------
          on backFile

          gFileIndex = gFileIndex - 1

          if gFileIndex = 1 then

          whichFile = gFileList[1]
          member("display").filename = gImagePath & whichFile
          member("display").picture = member ("display").picture
          updateStage
          sprite(17).enabled = FALSE -- deactivate back button

          -- gFileIndex = count(gFileList)
          end if

          if gFileIndex > 1 then

          whichFile = gFileList.getAt(gFileIndex)

          member("display").filename = gImagePath & whichFile
          member("display").picture = member ("display").picture
          updateStage
          end if
          end