现在的位置: 首页 > 综合 > 正文

Flash AS3声音视频编程

2013年06月22日 ⁄ 综合 ⁄ 共 4526字 ⁄ 字号 评论关闭

入门极好视频: http://www.enet.com.cn/eschool/video/flashas3/

《Flash CS3 AS3声音视频高级编程》共分为两章:第一章深入讲解了FLASH对于声音的编程,最后通过一个功能强大的MP3播放器进行演示,通过这一章的学习可以让你对于声音的处理有一个深入的掌握;第二章深入讲解了对于视频的处理,包括如何使用现有视频组件来控制视频。同时还讲了如何创建自己的控制外观。


声音示例:


[AS3.0编程教学]最全的声音控制方法
 http://jingyan.baidu.com/article/a948d651bc90a60a2ccd2e4c.html


视频示例: http://www.cuplayer.com/player/PlayerCodeCourse/2012/0914409.html

[Flex]NetStream动态加载视频利用SoundTransform控制音量

  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <!-- http://blog.flexexamples.com.sixxs.org/2008/03/01/displaying-a-video-in-flex-using-the-netconnection-netstream-and-video-classes/ --> 
  3. <mx:Application xmlns:mx="http://www.adobe.com.sixxs.org/2006/mxml" 
  4.                 layout="vertical" 
  5.                 verticalAlign="middle" 
  6.                 backgroundColor="white" 
  7.                 viewSourceURL="srcview/index.html" xmlns:local="*" 
  8.                 initialize="init();"> 
  9.  
  10.     <mx:Script> 
  11.         <![CDATA[
     
  12.             import mx.controls.Alert;
     
  13.             private var urlArr:Array=["http://221.122.36.143.sixxs.org/oa/video/1.flv", "http://221.122.36.143/oa/video/2.flv", "http://221.122.36.143/oa/video/p2.mp4"];
     
  14.             public function init():void{
     
  15.                 myVideo.urlArr = urlArr;
     
  16.                 myVideo.total = 100000;
     
  17. //              Alert.show("1==>>"+myVideo.urlArr.length);
     
  18.             }
     
  19.             
     
  20.         ]]> 
  21.     </mx:Script> 
  22.  
  23.     <local:mVideo id="myVideo"/> 
  24.  
  25. </mx:Application> 
  26.  
  27. 第二个文件  
  28. <?xml version="1.0" encoding="utf-8"?> 
  29. <mx:Panel xmlns:mx="http://www.adobe.com.sixxs.org/2006/mxml" 
  30.           creationComplete="setTransformVolume();"> 
  31.     <mx:Script> 
  32.         <![CDATA[
     
  33.             import mx.controls.Alert;
     
  34.             import mx.events.SliderEvent;
     
  35.  
  36.             private var nc:NetConnection;
     
  37.             private var ns:NetStream;
     
  38.             private var nc2:NetConnection;
     
  39.             private var ns2:NetStream;
     
  40.             private var video:Video;
     
  41.  
  42.             [Bindable]
     
  43.             public var urlArr:Array=null;
     
  44.             [Bindable]
     
  45.             public var total:Number=0;
     
  46.  
  47.             private var count:int=0;
     
  48.             private var finished1:int=1; //1:播放正在进行;0:播放结束
     
  49.             private var finished2:int=0; //1:播放正在进行;0:播放结束
     
  50.  
  51.             private var volumeTransform:SoundTransform;
     
  52.  
  53.             
     
  54.             private function setTransformVolume():void{
     
  55.                 volumeTransform=new SoundTransform();
     
  56.                 slider.value = volumeTransform.volume;
     
  57.                 slider.tickInterval = slider.snapInterval;
     
  58.                 slider.liveDragging = true;
     
  59.                 slider.addEventListener(Event.CHANGE, volumeChangeHandler);
     
  60.                 init();
     
  61.             }
     
  62.             
     
  63.             private function init():void
     
  64.             {
     
  65.                 Alert.show("" + total);
     
  66.                 
     
  67.                 var nsClient:Object={};
     
  68.                 nc=new NetConnection();
     
  69.                 nc.connect(null);
     
  70.                 ns=new NetStream(nc);
     
  71.                 ns.play(urlArr[count]);
     
  72.                 ns.client=nsClient;
     
  73.                 ns.soundTransform=volumeTransform;
     
  74.                 ns.addEventListener(NetStatusEvent.NET_STATUS, myTest1);
     
  75.                 
     
  76.                 video=new Video();
     
  77.                 video.name="video1";
     
  78.                 video.width=uic.width;
     
  79.                 video.height=uic.height;
     
  80.                 video.attachNetStream(ns);
     
  81.                 if (uic.getChildByName("video1") != null)
     
  82.                 {
     
  83.                     uic.removeChild(uic.getChildByName("video1"));
     
  84.                 }
     
  85.  
  86.                 count++;
     
  87.             }
     
  88.             private function volumeChangeHandler(event:SliderEvent):void {
     
  89.                 volumeTransform.volume = slider.value;
     
  90.                 ns.soundTransform = volumeTransform;
     
  91.                 ns2.soundTransform = volumeTransform;
     
  92.             }
     
  93.             private function init2():void
     
  94.             {
     
  95.  
  96.                 var nsClient:Object={};
     
  97.  
  98.                 nc2=new NetConnection();
     
  99.                 nc2.connect(null);
     
  100.                 ns2=new NetStream(nc2);
     
  101.                 ns2.play(urlArr[count]);
     
  102.                 ns2.client=nsClient;
     
  103.                 ns2.soundTransform=volumeTransform;
     
  104.                 ns2.addEventListener(NetStatusEvent.NET_STATUS, myTest2);
     
  105.                 
     
  106.                 video=new Video();
     
  107.                 video.name="video2";
     
  108.                 video.width=uic.width;
     
  109.                 video.height=uic.height;
     
  110.                 video.attachNetStream(ns2);
     
  111.                 if (uic.getChildByName("video2") != null)
     
  112.                 {
     
  113.                     uic.removeChild(uic.getChildByName("video2"));
     

抱歉!评论已关闭.