--   控制Flash音量的程序
property pSprite
property pConstraintSprite
property mouseState
property pFlashSprite
property pFlashSound

on getPropertyDescriptionList
  props = [:]
  props.addProp(#pFlashSprite, [#format: #integer, #default:2, #comment:"Flash精灵通道号:"])
  return props
end

on beginSprite me
  mouseState=0
  pSprite = sprite(me.spriteNum)
  pSprite.moveableSprite = TRUE
  pConstraintSprite = sprite(me.spriteNum - 1)
  pSprite.constraint = pConstraintSprite
  pFlashSound=sprite(pFlashSprite).newObject("sound")
  changetarget
end

on exitFrame me
  pass
end

on ChangeTarget me
  pSprite.locv = pConstraintSprite.locv
end

on mouseenter me
  cursor 280
end

on mouseleave me
  if mouseState=0 then cursor 0
end

on mousedown
  mouseState=1
end

on mouseup
  mouseState=0
  if not the mouseloc.inside(pSprite.rect) then
    cursor 0
  else
    cursor 280
  end if
  pFlashSound.setVolume((pConstraintSprite.height - pSprite.locv + pConstraintSprite.locv)*255.0/pConstraintSprite.height)
end