Discussion Question: How would you build a slide-show of images/text?

Less than Optimal Solution
Demonstrate if-else solution to this problem.
  • upload three images
  • set Button.Image to first image in designer
  • In blocks editor, use if-else-else to sequence through images. Go back to first image after last.
    • Note how file name of loaded image is used and must be set exactly. 
Discuss if-else solution:
  •      Would it be easy to add another item?
  •      Does the solution work for only a fixed set of pics, or could it work for dynamic (user-generated) set of pics?
List Solution
  • Store images in a list variable
  • Use an index to "walk" through the list
List-- a single variable (name) representing multiple memory cells

Index -- a number representing the current position in the list. 1 is the first position.

Important List functions
  • select list item
  • add items to list
  • length
Whiteboard demo: sketch blocks for letting user walk through list

    start index at 1

    on screen.initialize: 

    on nextButton.Click

    reaching the end of list

Demo: list solution to the slide show

Discussion: Is it easier to add new items to list? Can this handle user-generated data?

Your turn: President's Quiz


David Wolber,
Oct 23, 2012, 9:25 AM
David Wolber,
Oct 23, 2012, 9:26 AM
David Wolber,
Oct 23, 2012, 9:25 AM