Dynamically Creating / Loading FLV


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

Also see "Accessing Library elements"


Copy this code and paste it in your HTML
  1. var vc:NetConnection = new NetConnection();
  2. vc.connect(null);
  3. var vs:NetStream = new NetStream(vc);
  4. vs.addEventListener(NetStatusEvent.NET_STATUS ,onStatusEvent);
  5.  
  6. function onStatusEvent(stat:Object):void {
  7.  
  8. trace(stat.info.code);
  9.  
  10. }
  11.  
  12. var meta:Object = new Object();
  13. meta.onMetaData = function(meta:Object){
  14.  
  15. trace(meta.duration);
  16.  
  17. };
  18.  
  19. vs.client = meta;
  20.  
  21. var video:Video = new Video(stage.stageWidth, stage.stageHeight);
  22.  
  23. addChild(video);
  24.  
  25. video.attachNetStream(vs);
  26.  
  27. vs.play("flv/myFLV.flv");
  28.  
  29. //pauseButton is a movieclip in the library that is exported for actionscript with the class name pauseButton
  30. var PauseButton:pauseButton = new pauseButton();
  31.  
  32. PauseButton.y = stage.stageHeight - PauseButton.height/2;
  33. PauseButton.x = PauseButton.width/2;
  34.  
  35. PauseButton.addEventListener(MouseEvent.CLICK , PausePlayback);
  36. PauseButton.useHandCursor = true;
  37.  
  38. function CreatePlay() {
  39. this.addChild(PauseButton);
  40. }
  41.  
  42. function PausePlayback(e:Event):void {
  43.  
  44. vs.pause();
  45.  
  46. }
  47.  
  48. CreatePlay();

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.