Task

Create a window that has:

   a label that says   "There have been no clicks yet" 
   a button that says   "click me"


Upon clicking the button with the mouse, the label should change and show the number of times the button has been clicked.




on startMovie
 
  -- window settings
  _movie.stage.title = "Hello World!"
  _movie.stage.titlebarOptions.visible = TRUE
  _movie.stage.rect = rect(0,0,320, 240)
  _movie.centerStage = 1
 
  -- create a label (called "field" in Director)
  m = new(#field)
  m.name = "label"
  m.rect = rect(0,0,320,0)
  m.text = "There have been no clicks yet"
  m.alignment = "center"
 
  -- create sprite, assign field
  _movie.puppetSprite(1, TRUE)
  sprite(1).member = m
  sprite(1).loc = point(0,80)
 
  -- create a button
  m = new(#button)
  m.rect = rect(0,0,220,0)
  m.text = "click me"
  m.alignment = "center"
 
  -- create sprite, assign button
  _movie.puppetSprite(2, TRUE)
  sprite(2).member = m
  sprite(2).loc = point(50,105)
 
  -- create new script at runtime, assign it to button sprite
  m = new(#script)
  m.scriptType = #score
  m.scriptText = "on mouseDown"&RETURN&\
  "  m=member("&QUOTE&"label"&QUOTE&")"&RETURN&\
  "  m.text=string(integer(m.text)+1)"&RETURN&\
  "end"
  sprite(2).scriptInstanceList.add(m.script.new())
 
  -- force immediate update
  _movie.updateStage()
 
  -- show the window
  _movie.stage.visible = 1
 
end