FLV视频类播放器全屏切换完整AS代码示例

07-31
  1. function setFullScreen() {
  2. //fscommand("fullscreen", true);
  3. if (_root.logoCoolRabbit._visible == false) {
  4. if (Stage["displayState"] == "normal") {
  5. fscommand("fullscreen", true);
  6. Stage["displayState"] = "fullScreen";
  7. } else if (Stage["displayState"] == "fullScreen") {
  8. fscommand("fullscreen", false);
  9. Stage["displayState"] = "normal";
  10. }
  11. rootWidth = Stage.width;
  12. rootHeight = Stage.height;
  13. //复位控制栏
  14. clearInterval(controlBuffCoolTime);
  15. controlBuffCoolTime = null;
  16. clearInterval(controlBuff);
  17. controlBuffCool = 0;
  18. controlBuffEstimate = null;
  19. //复位标题栏
  20. clearInterval(playTitleBuffCoolTime);
  21. playTitleBuffCoolTime = null;
  22. clearInterval(playTitleBuff);
  23. playTitleBuffCool = 0;
  24. playTitleBuffEstimate = null;
  25. //重新设置组件位置
  26. moduleSet();
  27. //重新计算和设置播放组件尺寸比
  28. videoWidthSet = rootWidth;
  29. videoHeightvideoHeightSet = videoHeight/videoWidth*rootWidth;
  30. playAllModule.playFlvWindow._width = videoWidthSet;
  31. playAllModule.playFlvWindow._height = videoHeightSet;
  32. playAllModule.playFlvWindow._y = (rootHeight-playAllModule.playFlvWindow._height)/2;
  33. }
  34. }
  35. //全屏模式切换
  36. playAllModule.controlSet.buttonFullScreen.onPress = function() {
  37. setFullScreen();
  38. };
  39. //创建右键全屏及退出全屏菜单
  40. //var newnewMenu:ContextMenu = new ContextMenu();
  41. var newnewMenu:ContextMenu = new ContextMenu(menuHandler);
  42. //隐藏右键的一些标准菜单
  43. newMenu.hideBuiltInItems();
  44. // 在右键菜单中加入菜单项
  45. //var fs:ContextMenuItem = new ContextMenuItem("全屏", goFullScreen);
  46. var fs:ContextMenuItem = new ContextMenuItem("全屏", setFullScreen);
  47. newMenu.customItems.push(fs);
  48. //var xfs:ContextMenuItem = new ContextMenuItem("退出全屏", exitFullScreen);
  49. var xfs:ContextMenuItem = new ContextMenuItem("退出全屏", setFullScreen);
  50. newMenu.customItems.push(xfs);
  51. // 现在将右键菜单指定给场景中的movieclip.我当前指定给场景中的box.你也可以指定给_root
  52. this.menu = newMenu;
  53. /**
  54. function goFullScreen() {
  55. //Stage["displayState"] = "fullScreen";
  56. }
  57. function exitFullScreen() {
  58. //Stage["displayState"] = "normal";
  59. }
  60. **/
  61. // 定义开启和关闭全屏功能,取决于你当前处于哪一种状态下
  62. function menuHandler(obj, menuObj) {
  63. if (Stage["displayState"] == "normal") {
  64. // 如果你当前处在正常模式下,则goFullscreen可点击
  65. menuObj.customItems[0].enabled = true;
  66. menuObj.customItems[1].enabled = false;
  67. } else {
  68. // 如果你当前片在全屏模式下,则exitFullScreen可点击
  69. menuObj.customItems[0].enabled = false;
  70. menuObj.customItems[1].enabled = true;
  71. }
  72. }

flash播放器软件下载列表:

flash播放器大全下载中心 最新版flash播放器下载