--            本程序用于控制Flash的暂停播放
--      使用本程序请注意，所有的演员放在第一个cast中
--         暂停&播放按钮用图片（bitmap）格式的
global PauseOrPlay
property mysprite
property MyColor
property SwfSprites
property HWK_FlashNum--受控制的Flash精灵
property HWK_FlashPlay--Flash正在播放时应该显示的图片
property HWK_FlashStop--Flash停止播放时应该显示的图片
property FlashJudge

on beginsprite me
  PauseOrPlay=0
  mysprite=sprite(me.spritenum)
  if sprite(HWK_FlashNum).member.type<>#flash then
    FlashJudge=0
  else
    FlashJudge=1
  end if
  MyColor=Mysprite.color
  if FlashJudge=1 then
    case sprite(HWK_FlashNum).playing of
      1:
        mysprite.member=HWK_FlashPlay
      0:
        mysprite.member=HWK_FlashStop
      otherwise:nothing
    end case
  end if
end

on mouseenter me
  mysprite.cursor=280
end

on mouseleave me
  FlashPlay=HWK_FlashPlay.name&"h"
  FlashStop=HWK_FlashStop.name&"h"
  myname=Mysprite.member.name
  case myname of
    FlashPlay:Mysprite.member=HWK_FlashPlay
    FlashStop:Mysprite.member=HWK_FlashStop
    otherwise:nothing
  end case
  mysprite.cursor=-1
end

on mousedown me
  if PauseOrPlay=0 then
    PauseOrPlay=1
  else
    PauseOrPlay=0
  end if
  
  mysprite.cursor=-1
  if FlashJudge=1 then
    case sprite(HWK_FlashNum).playing of
      1:
        sprite(HWK_FlashNum).hold()
        mysprite.member=HWK_FlashStop
      0:
        sprite(HWK_FlashNum).play()
        mysprite.member=HWK_FlashPlay
      otherwise:nothing
    end case
  end if
end

on mouseUp me
  mysprite.cursor=280
end

on exitframe me
  case sprite(HWK_FlashNum).playing of
    1:
      mysprite.member=HWK_FlashPlay
    0:
      mysprite.member=HWK_FlashStop
    otherwise:nothing
  end case
end

on getPropertyDescriptionList
  set SwfSprites=[]
  repeat with spritenum=1 to the lastChannel
    case sprite(spritenum).member.type of
      (#flash):
        append SwfSprites,spritenum
      (#empty):
        next repeat      
    end case    
  end repeat
  vPDList=[:]
  setaProp vPDList, #HWK_FlashNum, [#comment:"需要控制的是哪个通道上的Flash精灵：",#format: #string,#default:1,#range:SwfSprites]
  setaProp vPDList, #HWK_FlashPlay, [#comment:"Flash正在播放时显示的图片：",#format: #bitmap,#default:""]
  setaProp vPDList, #HWK_FlashStop, [#comment:"Flash停止时显示的图片：",#format: #bitmap,#default:""]
  return vPDList
end getPropertyDescriptionList