content: function init()
    m.poster = m.top.findNode("poster")
    m.timer = m.top.findNode("timer")
    m.top.observeField("width", "onSizeChange")
    m.top.observeField("height", "onSizeChange")
    m.top.observeField("control", "onControlChange")
    m.timer.observeField("fire", "onTimerFireChange")
    m.direction = 1
    m.top.frameOffsets = []
    m.currentIndex = 0
  end function
  
  function onSizeChange()
    m.top.clippingRect = {
      width: m.top.width
      height: m.top.height
      x: 0
      y: 0
    }
  end function
  
  function onControlChange() as void
    if m.top.control = "start" and m.top.frameOffsets = invalid or m.top.frameOffsets.count() = 0 or m.top.spriteSheetUri = invalid or m.top.spriteSheetUri = ""
      ? "Please set Set the frames and sprite sheet uri"
      return
    end if
  
    m.timer.repeat = m.top.loopMode <> "once"
    m.timer.control = m.top.control
  end function
  
  function onTimerFireChange() as void
    if m.top.frameOffsets.count() = 0
      return
    end if
  
    m.currentIndex += m.direction
    if m.currentIndex < 0 'only could do this in ping pong
      m.currentIndex = 1
      direction = 1
    else if m.currentIndex = m.top.frameOffsets.count()
      if m.top.loopMode = "loop"
        m.currentIndex = 0
      else if m.top.loopMode = "ping-pong"
        m.currentIndex = m.top.frameOffsets.count() - 1
        direction = -1
      end if
    end if
  
    frame = m.top.frameOffsets[m.currentIndex]
    if frame <> invalid and frame.count() = 2
      m.poster.translation = [- frame[0], - frame[1]]
    end if
  end function