Video Fullscreen Background


/ Published in: ActionScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. // Prepare stage
  2. Stage.align ="TL";
  3.  
  4.  
  5. // VIDEO FULLSCREEN
  6. // ******************************************************************************************************
  7.  
  8. // Prepare connection
  9. var myNetConnection:NetConnection = new NetConnection();
  10. myNetConnection.connect(null);
  11.  
  12. // Stream video
  13. // "video" is the video symbol in the library
  14. var myNetStream:NetStream = new NetStream(myNetConnection);
  15. video.attachVideo(myNetStream);
  16.  
  17. // Smooth
  18. video.smoothing = true;
  19.  
  20. // Start playing
  21. myNetStream.play("video.flv");
  22. myNetStream.seek(0.3);
  23.  
  24.  
  25. // VIDEO SIZE
  26. function setVideoSize():Void
  27. {
  28. // Stage Dimensions
  29. var wStage:Number = Stage.width;
  30. var hStage:Number = Stage.height;
  31.  
  32. // Adapt based on width
  33. video._width = Stage.width;
  34. video._yscale = video._xscale;
  35.  
  36. // Adapth based on height
  37. if( video._height < hStage )
  38. {
  39. //scale
  40. video._height = Stage.height;
  41. video._xscale = video._Yscale;
  42.  
  43. // centered
  44. video._x = ((video._width - Stage.width) / 2) * (-1);
  45. }
  46. }
  47.  
  48.  
  49. // RESIZE STAGE
  50. // ******************************************************************************************************
  51.  
  52. // Create listener
  53. var resizeStage:Object = new Object();
  54.  
  55. // Detect resize
  56. resizeStage.onResize = function()
  57. {
  58. // Video
  59. setVideoSize();
  60. }
  61.  
  62. // Activates listener
  63. Stage.addListener(resizeStage);

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.