AS3.0制作的一款视频播放器(可更换皮肤)

预览效果:

 

效果图: 

AS3.0制作的一款视频播放器(可更换皮肤)

 预览地址: http://url.cn/1PrwDU/?.swf(加载可能比较慢一些)

此播放器可通过xml文件加载视频文件,也可通过调用外部JS文件接收视频地址参数进行加载,看个人喜好了,待会儿会将所有源码贴出,也可下载至本地进行查看...

废话不多话,看源码吧:

首先是PlayerMedia包中的一些AS类:

PlayerVideo.as

 

View Code
package PlayerMedia 
{
    import flash.events.AsyncErrorEvent;
    import flash.events.IOErrorEvent;
    import flash.events.MouseEvent;
    import flash.events.NetStatusEvent;
    import flash.media.SoundTransform;
    import flash.media.Video;
    import flash.net.NetConnection;
    import flash.net.NetStream;
    import flash.text.TextField;
    import VideoInterface.InterfaceButton;
    import VideoControls.ButtonFOControl;
    import VideoInterface.Draws;
    import VideoControls.SkinsManager;
    import VideoInterface.loading;
    import VideoControls.GetAndSetStage;
     // import Main;
     /* *
     * 封装的Video类
     * @author xiaofeng
     
*/
    public class PlayerVideo extends Video
    {
        private  var netconnction:NetConnection;
        private  var netstream:NetStream;
        private  var videosound:SoundTransform;
        private  var videourl:String;
        public static  var VideoTime:Number = 0;
        public static  var video_width:Number;
        public static  var video_height:Number;
        private  var playminute:Number;
        private  var playsecond:Number;
        private  var playmin_str:String;
        private  var playsec_str:String;
        private  var playtimelytime:String;
        private  var num:Number = ButtonFOControl.get_set_Seconds;
        private  var timenum:Number = 0;
        public  var colors:uint = SkinsManager.getandsetcolors;
        private  var Volume:Number; // 记录原始音量
        private  var myloading:loading;
        public  var LoadState:TextField =  new TextField();
        public  var videoprocess:VideoProcess;
        private  var delboo:Boolean =  false;
        public  function PlayerVideo(): void
        {
            CustomClient.setvideo( this);
            netconnction =  new NetConnection();
            netconnction.addEventListener(NetStatusEvent.NET_STATUS, NetStatusHalder);
            netconnction.addEventListener(AsyncErrorEvent.ASYNC_ERROR, AsyncErrorHalder);
            netconnction.addEventListener(IOErrorEvent.IO_ERROR, IOErrorHalder);
            netconnction.connect( null);
            netstream =  new NetStream(netconnction);
            netstream.client =  new CustomClient;
            videosound =  new SoundTransform();
            videosound.volume = 1;
            netstream.soundTransform = videosound;
             this.attachNetStream(netstream);
             this.cacheAsBitmap =  true;
            netstream.checkPolicyFile =  true;
            netstream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, AsyncErrorHalder);
            netstream.addEventListener(NetStatusEvent.NET_STATUS, NetStatusHalder);
            netstream.addEventListener(IOErrorEvent.IO_ERROR, IOErrorHalder);
        }
        private  function NetStatusHalder(evt:NetStatusEvent): void
        {
             switch (evt.info.code) 
            {
                 case "NetStream.Play.StreamNotFound":
                    trace("找不到视频");
                    LoadState.text = "视频文件不存在";
                     break;
                 case "NetStream.Play.Failed":
                    trace("视频播放失败");
                    LoadState.text = "加载视频文件失败";
                     break;
                 case "NetStream.Play.Stop" :
                trace("播放完成");
                     if (myloading.parent !=  null)
                    {
                        GetAndSetStage.stages.removeChild(myloading);
                        GetAndSetStage.stages.removeChild(LoadState);
                    }
                    InterfaceButton.puasebtn.visible =  false;
                    InterfaceButton.playbtn.visible =  true;
                    ButtonFOControl.stopboo =  true;
                    ButtonFOControl.btnboo =  true;
                    ButtonFOControl.processboo =  true;
                    videoprocess =  new VideoProcess();
                    GetAndSetStage.stages.addChild(videoprocess);
                    videoprocess.Replaycount.addEventListener(MouseEvent.CLICK, Replaycount_click);
                     if (delboo && videoprocess !=  null)
                    {
                        delboo =  false;
                        GetAndSetStage.stages.removeChild(videoprocess);
                        videoprocess.Replaycount.removeEventListener(MouseEvent.CLICK, Replaycount_click);
                        videoprocess =  null;
                    }
                     break;
                 case "NetStream.Play.Start" :
                    trace("视频开始播放");
                    GetAndSetStage.stages.removeChild(myloading);
                    GetAndSetStage.stages.removeChild(LoadState);
                    ButtonFOControl.btnboo =  true;
                     if (InterfaceButton.playbtn.visible)
                    {
                        InterfaceButton.playbtn.visible =  false;
                        InterfaceButton.puasebtn.visible =  true;
                        InterfaceButton.playbtn.buttonMode =  true;
                        InterfaceButton.puasebtn.buttonMode =  true;
                        InterfaceButton.stopbtn.buttonMode =  true;
                        InterfaceButton.RWbtn.buttonMode =  true;
                        InterfaceButton.FFbtn.buttonMode =  true;
                    }
                     break;
                 case "NetStream.Buffer.Empty" :
                    trace("数据的接收速度不足以填充缓冲区");
                    GetAndSetStage.stages.addChildAt(myloading, 0);
                    GetAndSetStage.stages.addChildAt(LoadState, 0);
                    InterfaceButton.playbtn.visible =  true;
                    InterfaceButton.puasebtn.visible =  false;
                    ButtonFOControl.btnboo =  false;
                     break;
                 case "NetStream.Buffer.Full" :
                    trace("缓冲区已满并且流将开始播放");
                     if (myloading.parent !=  null)
                    {
                        GetAndSetStage.stages.removeChild(myloading);
                        GetAndSetStage.stages.removeChild(LoadState);
                    }
                    InterfaceButton.puasebtn.visible =  true;
                    InterfaceButton.playbtn.visible =  false;
                    ButtonFOControl.btnboo =  true;
                     break;
                 case "NetStream.Buffer.Flush" :
                    trace("数据已完成流式处理,剩余的缓冲区将被清空");
                    ButtonFOControl.btnboo =  true;
                     break;
                 case "NetStream.Seek.Notify" :
                    trace("搜寻操作完成");
                     break;
                 case "NetStream.Seek.InvalidTime":
                    trace("无法跳转到指定时间点播放");
                    netstream.seek(netstream.time);
                    delboo =  true;
                     break;
            }
        }
         // 处理点击重新播放按钮事件
        private  function Replaycount_click(evt:MouseEvent): void
        {
            ReplayVideo();
            evt.target.removeEventListener(MouseEvent.CLICK, Replaycount_click);
            GetAndSetStage.stages.removeChild(videoprocess);
            videoprocess =  null;
        }
         // 处理错误
        private  function AsyncErrorHalder(evt:AsyncErrorEvent): void
        {
            trace("异步错误");
        }
        private  function IOErrorHalder(evt:IOErrorEvent): void
        {
            trace("流错误");
        }
         /* *
         * 播放视频方法
         
*/
        public  function playvideo(url:String): void
        {
            netstream.play(url);
            myloading =  new loading();
            GetAndSetStage.stages.addChildAt(myloading, 0);
            myloading.x = GetAndSetStage.stages.stageWidth / 3;
            myloading.y = GetAndSetStage.stages.stageHeight / 4;
            LoadState.textColor = 0xffffff;
            LoadState.text = "加载中,请稍后...";
            LoadState.selectable =  false;
            LoadState.mouseEnabled =  false;
            GetAndSetStage.stages.addChildAt(LoadState,0);
            LoadState.x = myloading.x + myloading.width + 80;
            LoadState.y = myloading.y + myloading.height + 65;
        }
         /* *
         * 播放时间计算方法
         
*/
        public  function PlayComputTime():String
        {
            playminute = Math.floor(netstream.time / 60);
            playsecond = Math.round(netstream.time % 60);
             if (playminute >= 10)
            {
                playmin_str = String(playminute);
            }
             else
            {
                playmin_str = "0" + playminute;
            }
             if (playsecond >= 10)
            {
                playsec_str = String(playsecond);
            }
             else
            {
                playsec_str = "0" + playsecond;
            }
            playtimelytime = playmin_str + ":" + playsec_str;
             return playtimelytime;
        }
         /* *
         * 加载进度百分比
         
*/
        public  function loadprogress():Number
        {
             return netstream.bytesLoaded / netstream.bytesTotal;
        }
         /* *
         * 视频播放百分比
         
*/
        public  function playprogress():Number
        {
             return netstream.time / VideoTime;
        }
         /* *
         * 静音||恢复音量
         
*/
        public  function Mute(w:Number): void
        {
             if (videosound.volume != 0)
            {
                Volume = videosound.volume;
                videosound.volume = 0;
            }
             else
            {
                videosound.volume = Volume;
            }
            reset(videosound.volume * w);
            netstream.soundTransform = videosound;
            InterfaceButton.soundbar.x = InterfaceButton.soundvalue.x + InterfaceButton.soundvalue.width - InterfaceButton.soundbar.width / 2;
        }
         /* *
         * 重新调整音量元件位置等方法
         
*/
        private  function reset(DW:Number): void
        {
            Draws.drawroundrectsNotreturnvalue(InterfaceButton.soundvalue, DW, 6, 3, 0, 0, colors);
             switch( true)
            {
                 case DW == 0:
                Draws.DrawsLineStyle(InterfaceButton.soundline, 0, 0, 1, colors, 1);
                 break;
                 case DW > 0 && DW <= 20:
                Draws.DrawsLineStyle(InterfaceButton.soundline, 1, 0, 1, colors, 1);
                 break;
                 case DW > 20 && DW <= 40:
                Draws.DrawsLineStyle(InterfaceButton.soundline, 2, 0, 1, colors, 1);
                 break;
                 case DW > 40 && DW <= 60:
                Draws.DrawsLineStyle(InterfaceButton.soundline, 3, 0, 1, colors, 1);
                 break;
                 case DW > 60 && DW <= 80:
                Draws.DrawsLineStyle(InterfaceButton.soundline, 4, 0, 1, colors, 1);
                 break;
            }
        }
         /* *
         * 滑块拖动改变声音大小方法
         
*/
        public  function DragBarSetSoundVolume(w:Number,ow:Number):Number
        {
            videosound.volume = (1 / ow) * w;
            reset(videosound.volume * ow);
            netstream.soundTransform = videosound;
            
             return videosound.volume;
        }
         /* *
         * 恢复播放方法
         
*/
        public  function resumevideo(): void
        {
            netstream.resume();
            InterfaceButton.playbtn.visible =  false;
            InterfaceButton.puasebtn.visible =  true;
            ButtonFOControl.btnboo =  true;
        }
         /* *
         * 暂停播放方法
         
*/
        public  function pausevideo(): void
        {
            netstream.pause();
            InterfaceButton.puasebtn.visible =  false;
            InterfaceButton.playbtn.visible =  true;
            ButtonFOControl.btnboo =  false;
        }
         /* *
         * 停止播放方法
         
*/
        public  function stopvideo(): void
        {
             // 停止播放并清除视频当前画面
            pausevideo();
             this.clear();
             // 设置后停止记录信息
            ButtonFOControl.stopboo =  true;
            ButtonFOControl.btnboo =  false;
        }
         /* *
         * 重新播放
         
*/
        public  function ReplayVideo(): void
        {
            netstream.seek(0);
            resumevideo();
            ButtonFOControl.stopboo =  false;
            InterfaceButton.playbtn.visible =  false;
            InterfaceButton.puasebtn.visible =  true;
        }
         /* *
         * 快进方法
         
*/
        public  function FastForward(): void 
        {
            timenum = netstream.time + num;
            netstream.seek(timenum);
        }
         /* *
         * 快退方法
         
*/
        public  function Rewind(): void
        {
            timenum = netstream.time - num;
            netstream.seek(timenum);
        }
         /* *
         * 跳转方法
         
*/
        public  function JumpVideo(videotime:Number): void
        {
            netstream.seek(videotime);
        }
    }
}

CustomClient.as

 

View Code
package PlayerMedia 
{
    import flash.media.Video;
    import VideoControls.GetAndSetStage;
    import tools.CalculateVideoSize;
    import tools.VideoTime;
     /* *
     * 自定义客户端
     * @author xiaofeng
     
*/
    public class CustomClient 
    {
        private static  var stagevideo:Video;
        public  function CustomClient(): void
        {
        }
        public  function onMetaData(info:Object): void
        {
            VideoTime.ComputTime(info.duration);
            PlayerVideo.VideoTime = info.duration;
            PlayerVideo.video_width = info.width;
            PlayerVideo.video_height = info.height;
            stagevideo.width = info.width;
            stagevideo.height = info.height;
            CalculateVideoSize.setvideosize(stagevideo, info.width, info.height);
        }
         /* *
        * 设置video
        
*/
        public static  function setvideo(video:Video): void
        {
            stagevideo = video;
        }
    }
}

VideoProcess.as

 

View Code
package PlayerMedia 
{
    import flash.display.Loader;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.IOErrorEvent;
    import flash.events.MouseEvent;
    import flash.net.URLRequest;
    import flash.text.TextField;
    import flash.text.TextFormat;
    import VideoInterface.Draws;
    import VideoControls.GetAndSetStage;
    import VideoInterface.InterfaceButton;
    import com.greensock.TweenLite;
    import com.greensock.easing.*;
     /* *
     * 当前视频播放完成后处理类
     * @author xiaofeng
     
*/
    public class VideoProcess extends Sprite
    {
        private  var processbg:Sprite; // 背景
        private  var Replaybtnbg:Sprite;
        public  var Replaycount:Sprite =  new Sprite();
        public  function VideoProcess() 
        {
            processbg = Draws.drawroundrects(600, 465, 0, 0, 0, 0x4D4D4D, 0.5);
             this.addChild(processbg);
             var ImageLoader:Loader =  new Loader();
            ImageLoader.load( new URLRequest(InterfaceButton.replayImageURL));
            ImageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, ImageCom);
            ImageLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ErrorFunc);
        }
        private  function ImageCom(evt:Event): void
        {
            Replaybtnbg =  new Sprite();
             var text:TextField =  new TextField();
             var textformat:TextFormat =  new TextFormat();
            Draws.drawroundrectsNotreturnvalue(Replaybtnbg, 60, 60, 6, 0, 0, 0x000000);
            Replaycount.addChild(Replaybtnbg);
            Replaycount.addChild(evt.target.content);
            evt.target.content.x = (Replaybtnbg.width - evt.target.content.width) / 2;
            evt.target.content.y = 5;
            text.text = "重播";
            textformat.font = "宋体";
            textformat.size = 16;
            textformat.color = 0xffffff;
            text.setTextFormat(textformat);
            text.selectable =  false;
            text.mouseEnabled =  false;
            text.width = text.textWidth + 4;
            text.height = text.textHeight + 4;
            Replaycount.addChild(text);
            text.x = (Replaybtnbg.width - text.width) / 2;
            text.y = 35;
            Replaybtnbg.alpha = 0;
            Replaycount.buttonMode =  true;
            Replaycount.addEventListener(MouseEvent.MOUSE_OVER, Replaycount_over);
            Replaycount.addEventListener(MouseEvent.MOUSE_OUT, Replaycount_out);
            processbg.addChild(Replaycount);
            Replaycount.x = processbg.width - Replaycount.width - 30;
            Replaycount.y = 30;
        }
        private  function ErrorFunc(evt:IOErrorEvent): void
        {
            trace("加载失败");
            evt.target.removeEventListener(IOErrorEvent.IO_ERROR, ErrorFunc);
        }
        private  function Replaycount_over(evt:MouseEvent): void
        {
            TweenLite.to(Replaybtnbg, 1, { alpha:1, ease:Back.easeOut } );
        }
        private  function Replaycount_out(evt:MouseEvent): void
        {
            TweenLite.to(Replaybtnbg, 1, { alpha:0, ease:Back.easeOut } );
        }
        public  function removeReplaycount(): void
        {
            
        }
    }
}

VideoInterface包

Draws.as

 

View Code
package VideoInterface 
{
    import flash.display.DisplayObject;
    import flash.display.Sprite;
    import flash.filters.BitmapFilter;
    import flash.filters.BitmapFilterQuality;
    import flash.filters.DropShadowFilter;
    import flash.geom.Point;
     /* *
     * ...
     * @author xiaofeng
     
*/
    public class Draws 
    {
        public  function Draws() 
        {
            
        }
         /* *
         * 绘制矩形或圆角矩形方法,需返回值
         
*/
        public static  function drawroundrects(width:Number,height:Number,ellipse:Number,x:Number = 0,y:Number = 0,colors:uint = 0xFFFFFF,alphas:Number = 1,border:Boolean =  false,lineboo:Boolean =  false):Sprite
        {
             var roundrect:Sprite =  new Sprite();
            roundrect.graphics.beginFill(colors, alphas);
             if (lineboo)
            {
                roundrect.graphics.lineStyle(1, 0x000000,0.3);
            }
            roundrect.graphics.drawRoundRect(x, y, width, height, ellipse);
            roundrect.graphics.endFill();
             if (border)
            {
                 var filter:BitmapFilter = getBitmapFilter();
                 var myFilters:Array =  new Array();
                myFilters.push(filter);
                roundrect.filters = myFilters;
            }
            
             return roundrect;
        }
         /* *
         * 绘制矩形或圆角矩形方法,无需返回值
         
*/
        public static  function drawroundrectsNotreturnvalue(obj:Sprite,width:Number,height:Number,ellipse:Number,x:Number = 0,y:Number = 0,colors:uint = 0xFFFFFF,alphas:Number = 1,border:Boolean =  false,lineboo:Boolean =  false): void
        {
            obj.graphics.clear();
            obj.graphics.beginFill(colors, alphas);
             if (lineboo)
            {
                obj.graphics.lineStyle(1, 0x000000,0.2);
            }
            obj.graphics.drawRoundRect(x, y, width, height, ellipse);
            obj.graphics.endFill();
             if (border)
            {
                 var filter:BitmapFilter = getBitmapFilter();
                 var myFilters:Array =  new Array();
                myFilters.push(filter);
                obj.filters = myFilters;
            }
        }
        private static  function getBitmapFilter():BitmapFilter
        {
             var color:Number = 0x000000;
             var angle:Number = 70;
             var alpha:Number = 0.6;
             var blurX:Number = 3;
             var blurY:Number = 3;
             var distance:Number = 2;
             var strength:Number = 0.5;
             var inner:Boolean =  true;
             var knockout:Boolean =  false;
             var quality:Number = BitmapFilterQuality.HIGH;
            
             return  new DropShadowFilter(distance,angle,color,alpha,blurX,blurY,strength,quality,inner,knockout);
        }
         /* *
         * 绘制线条方法
         
*/
        public static  function DrawsLineStyle(obj:Sprite,nums: int,distance:Number, thickness:Number, colors:uint, alphas:Number = 1): void
        {
            obj.graphics.clear();
             for ( var i: int = 0; i <= nums; i++ )
            {
                obj.graphics.lineStyle(thickness, colors, alphas);
                obj.graphics.moveTo(distance + i*2, distance + i*2);
                obj.graphics.lineTo(distance + i*2, distance - i*2);
            }
            obj.graphics.endFill();
        }
         /* *
         * 绘制提示框方法
         
*/
        public static  function DrawsPromptBox(colors:uint,alphas:Number,stylesize:Number,stylecolor:uint,stylealpha:Number,boxwidth:Number,boxheight:Number,Trianglewidth:Number,Triangleheight:Number):Sprite
        {
             var sp:Sprite =  new Sprite();

            sp.graphics.beginFill(colors, alphas );
            sp.graphics.lineStyle(stylesize, stylecolor, stylealpha);
             // 起点
            sp.graphics.moveTo(0,0);
            sp.graphics.lineTo(0,boxheight);
            sp.graphics.lineTo((boxwidth - Trianglewidth)/2,boxheight);
            
             // 中点
            sp.graphics.lineTo(boxwidth/2,boxheight + Triangleheight);
            
            sp.graphics.lineTo((boxwidth - Trianglewidth)/2 + Trianglewidth ,boxheight);
            sp.graphics.lineTo(boxwidth,boxheight);
            sp.graphics.lineTo(boxwidth, 0);
             // 终点
            sp.graphics.lineTo(0,0);

            sp.graphics.endFill();
            
             return sp;
        }
    }

}

InterfaceButton.as

 

View Code
package VideoInterface 
{
    import flash.display.MovieClip;
    import flash.display.Sprite;
    import flash.text.TextField;
    import flash.text.TextFormat;
     /* *
     * 定义界面各按钮
     * @author xiaofeng
     
*/
    public class InterfaceButton 
    {
         /* *
         * 菜单背景高度
         
*/
        public static  var ListHeight:Number = 35;
         /* *
         * 播放按钮
         
*/
        public static  var playbtn:Sprite =  new Sprite();
         /* *
         * 暂停按钮
         
*/
        public static  var puasebtn:Sprite =  new Sprite();
         /* *
         * 停止按钮
         
*/
        public static  var stopbtn:Sprite =  new Sprite();
         /* *
         * 工具按钮
         
*/
        public static  var toolsbtn:Sprite =  new Sprite();
         /* *
         * 视频调节滑块
         
*/
        public static  var videobarbtn:Sprite =  new Sprite();
         /* *
         * 更换皮肤按钮
         
*/
        public static  var skinbtn:Sprite =  new Sprite();
         /* *
         * 喇叭按钮
         
*/
        public static  var hornbtn:Sprite =  new Sprite();
         /* *
         * 快进按钮
         
*/
        public static  var FFbtn:Sprite =  new Sprite();
         /* *
         * 快退按钮
         
*/
        public static  var RWbtn:Sprite =  new Sprite();
         /* *
         * 进度条背景
         
*/
        public static  var loadbg:Sprite;
         /* *
         * 加载进度条
         
*/
        public static  var loadprogress:Sprite =  new Sprite();
         /* *
         * 播放进度条
         
*/
        public static  var playprogress:Sprite =  new Sprite();
         /* *
         * 全屏按钮
         
*/
        public static  var Fullbtn:Sprite =  new Sprite();
        public static  var playtimestring:String = "00:00";
        public static  var conttimestring:String = "00:00";
        public static  var textformat:TextFormat =  new TextFormat();
         /* *
         * 时间显示
         
*/
        public static  var TimeText:TextField =  new TextField();
         /* *
         * 声音线条
         
*/
        public static  var soundline:Sprite =  new Sprite();
         /* *
         * 声音大小显示背景
         
*/
        public static  var soundvaluebg:Sprite;
         /* *
         * 声音大小显示
         
*/
        public static  var soundvalue:Sprite =  new Sprite();
         /* *
         * 声音大小滑块
         
*/
        public static  var soundbar:Sprite =  new Sprite();
         /* *
         * 重新播放按钮图片地址
         
*/
        public static  var replayImageURL:String;
    }
}

InterfaceInitialization.as

 

View Code
package VideoInterface 
{
    import flash.display.Sprite;
    import flash.display.Stage;
    import flash.text.TextFormat;
    import VideoControls.SkinsManager;
    import VideoControls.GetAndSetStage;
    import tools.CalculateVideoSize;
     /* *
     * 调整(初始化)按钮各位置
     * @author xiaofeng
     
*/
    public class InterfaceInitialization extends Sprite
    {
        private  var stages:Stage = GetAndSetStage.stages;
        public  var munebackground:Sprite; 
        private  var heights:Number;
        public  var timetextbg:Sprite;
        public  var soundbg:Sprite;
        private  var toolsbg:Sprite;
        public  var skinbg:Sprite;
        private  var fullbg:Sprite;
        private  var stage_width:Number = CalculateVideoSize.stage_width;
        private  var stage_height:Number = CalculateVideoSize.stage_height;
        private  var listheight:Number = InterfaceButton.ListHeight / 2;
        public  function InterfaceInitialization() 
        {    
        }
         /* *
         * 定义对象方法
         
*/
        public  function Definedobjects(): void
        {
             for ( var i: int = 0; i < SkinsManager.skincont.length; i++ )
            {
                 var obj:Object = SkinsManager.skincont[i] as Object;
                 switch(obj.names)
                {
                     case "play":
                    InterfaceButton.playbtn.addChild(obj.ico);
                     break;
                     case "puase":
                    InterfaceButton.puasebtn.addChild(obj.ico);
                     break;
                     case "stop":
                    InterfaceButton.stopbtn.addChild(obj.ico);
                     break;
                     case "tools":
                    InterfaceButton.toolsbtn.addChild(obj.ico);
                     break;
                     case "videobar":
                    InterfaceButton.videobarbtn.addChild(obj.ico);
                     break;
                     case "skin":
                    InterfaceButton.skinbtn.addChild(obj.ico);
                     break;
                     case "horn":
                    InterfaceButton.hornbtn.addChild(obj.ico);
                     break;
                     case "FF":
                    InterfaceButton.FFbtn.addChild(obj.ico);
                     break;
                     case "RW":
                    InterfaceButton.RWbtn.addChild(obj.ico);
                     break;
                     case "Full":
                    InterfaceButton.Fullbtn.addChild(obj.ico);
                     break;
                }
            }
        }
         /* *
         * 定义按钮初始位置方法
         
*/
        public  function Custombuttonposition(): void
        {
            munebackground = Draws.drawroundrects(stages.stageWidth, InterfaceButton.ListHeight, 0);
             this.addChild(munebackground);
            munebackground.y = stages.stageHeight - munebackground.height;
            heights = InterfaceButton.playbtn.height;
             // 显示快退按钮
            munebackground.addChild(InterfaceButton.RWbtn);
            InterfaceButton.RWbtn.x = 1
             // 显示快进按钮
            munebackground.addChild(InterfaceButton.FFbtn);
            InterfaceButton.FFbtn.x = munebackground.width - 12;
             // 绘制显示加载背景
            InterfaceButton.loadbg = Draws.drawroundrects(stages.stageWidth - 40, 6, 4, 0, 0, 0xBBBBBB);
            munebackground.addChild(InterfaceButton.loadbg);
            InterfaceButton.loadbg.x = InterfaceButton.RWbtn.x + 18;
            InterfaceButton.loadbg.y = InterfaceButton.RWbtn.y + 3;
            munebackground.addChild(InterfaceButton.loadprogress);
            InterfaceButton.loadprogress.x = InterfaceButton.loadbg.x;
            InterfaceButton.loadprogress.y = InterfaceButton.loadbg.y;
            munebackground.addChild(InterfaceButton.playprogress)
            InterfaceButton.playprogress.x = InterfaceButton.loadbg.x;
            InterfaceButton.playprogress.y = InterfaceButton.loadbg.y;
            munebackground.addChild(InterfaceButton.videobarbtn);
            InterfaceButton.videobarbtn.x = InterfaceButton.playprogress.x + InterfaceButton.playprogress.width - InterfaceButton.videobarbtn.width / 2;
            InterfaceButton.videobarbtn.y = InterfaceButton.loadbg.y - 0.5;
            InterfaceButton.videobarbtn.visible =  false;
             // 显示播放按钮
            munebackground.addChild(InterfaceButton.playbtn);
            InterfaceButton.playbtn.x = 10;
            InterfaceButton.playbtn.y = 13;
             // 显示暂停按钮,且初始隐藏
            munebackground.addChild(InterfaceButton.puasebtn);
            InterfaceButton.puasebtn.x = InterfaceButton.playbtn.x;
            InterfaceButton.puasebtn.y = InterfaceButton.playbtn.y;
            InterfaceButton.puasebtn.visible =  false;
             // 显示停止按钮
            munebackground.addChild(InterfaceButton.stopbtn);
            InterfaceButton.stopbtn.x = InterfaceButton.playbtn.x + InterfaceButton.playbtn.width + 2;
            InterfaceButton.stopbtn.y = InterfaceButton.playbtn.y;
             // 显示时间背景以及时间对象
            timetextbg = Draws.drawroundrects(84, heights, 3, 0, 0, SkinsManager.getandsetcolors,0.7 , true);
            munebackground.addChild(timetextbg);
            timetextbg.x = InterfaceButton.stopbtn.x + InterfaceButton.stopbtn.width + 2;
            timetextbg.y = InterfaceButton.stopbtn.y;
            InterfaceButton.textformat.font = "Lingoes Unicode";
            InterfaceButton.textformat.size = 14;
            InterfaceButton.textformat.color = 0x000000;
            InterfaceButton.TimeText.text = InterfaceButton.playtimestring + "/" + InterfaceButton.conttimestring;
            InterfaceButton.TimeText.setTextFormat(InterfaceButton.textformat);
            InterfaceButton.TimeText.width = InterfaceButton.TimeText.textWidth + 4;
            timetextbg.addChild(InterfaceButton.TimeText);
            InterfaceButton.TimeText.x = 2;
            InterfaceButton.TimeText.y = -2;
            InterfaceButton.TimeText.selectable =  false;
             // 绘制声音控件背景
            soundbg = Draws.drawroundrects(120, heights, 3, 0, 0, 0xD1D1D1);
            munebackground.addChild(soundbg);
            soundbg.x = munebackground.width - 198;
            soundbg.y = InterfaceButton.playbtn.y;
             // 显示声音控件对象
            soundbg.addChild(InterfaceButton.hornbtn);
            InterfaceButton.hornbtn.x = 4;
            InterfaceButton.hornbtn.y = -1;
            Draws.DrawsLineStyle(InterfaceButton.soundline,4,0, 1, SkinsManager.getandsetcolors, 1);
            soundbg.addChild(InterfaceButton.soundline);
            InterfaceButton.soundline.x = 13;
            InterfaceButton.soundline.y = 9;
            InterfaceButton.soundvaluebg = Draws.drawroundrects(80, 6, 3, 0, 0, 0xBBBBBB, 1, true);
            soundbg.addChild(InterfaceButton.soundvaluebg);
            InterfaceButton.soundvaluebg.x = 30;
            InterfaceButton.soundvaluebg.y = 6;
            Draws.drawroundrectsNotreturnvalue(InterfaceButton.soundvalue,80, 6, 3, 0, 0, SkinsManager.getandsetcolors);
            soundbg.addChild(InterfaceButton.soundvalue);
            InterfaceButton.soundvalue.x = InterfaceButton.soundvaluebg.x;
            InterfaceButton.soundvalue.y = InterfaceButton.soundvaluebg.y;
             var sb:Sprite = Draws.drawroundrects(6, 10, 6, 0, 0, SkinsManager.getandsetcolors, 0.6);
            InterfaceButton.soundbar.addChild(sb);
            soundbg.addChild(InterfaceButton.soundbar);
            InterfaceButton.soundbar.x = 106;
            InterfaceButton.soundbar.y = 4;
            InterfaceButton.soundbar.buttonMode =  true;
            InterfaceButton.hornbtn.buttonMode =  true;
             // 设置工具按钮背景等
            toolsbg = Draws.drawroundrects(20, heights, 3,0,0,0xD1D1D1);
            munebackground.addChild(toolsbg);
            toolsbg.x = soundbg.x + soundbg.width + 2;
            toolsbg.y = soundbg.y;
            toolsbg.addChild(InterfaceButton.toolsbtn);
            InterfaceButton.toolsbtn.x = 2;
            InterfaceButton.toolsbtn.buttonMode =  true;
             // 设置皮肤按钮背景等
            skinbg = Draws.drawroundrects(20, heights, 3, 0, 0, 0xD1D1D1);
            munebackground.addChild(skinbg);
            skinbg.x = toolsbg.x + toolsbg.width + 2;
            skinbg.y = toolsbg.y;
            skinbg.addChild(InterfaceButton.skinbtn);
            InterfaceButton.skinbtn.x = 1;
            InterfaceButton.skinbtn.y = 1;
            InterfaceButton.skinbtn.buttonMode =  true;
             // 设置全屏按钮背景等
            fullbg = Draws.drawroundrects(20, heights, 3, 0, 0, 0xD1D1D1);
            munebackground.addChild(fullbg);
            fullbg.x = skinbg.x + skinbg.width + 2;
            fullbg.y = skinbg.y;
            fullbg.addChild(InterfaceButton.Fullbtn);
            InterfaceButton.Fullbtn.x = 3;
            InterfaceButton.Fullbtn.y = 2;
            InterfaceButton.Fullbtn.buttonMode =  true;
        }
         /* *
         * 当舞台宽高发生变化时,重置界面元素位置方法
         
*/
        public  function ResetPosition(StageWidth:Number, StageHeight:Number): void
        {
            Draws.drawroundrectsNotreturnvalue(munebackground, StageWidth, InterfaceButton.ListHeight, 0);
            munebackground.x = (stage_width - StageWidth) / 2;
            munebackground.y = (stage_height - StageHeight) / 2 + StageHeight - listheight;
            InterfaceButton.FFbtn.x = StageWidth - 12;
            Draws.drawroundrectsNotreturnvalue(InterfaceButton.loadbg,StageWidth - 40, 6, 4, 0, 0, 0x696969);
            InterfaceButton.loadbg.x = InterfaceButton.RWbtn.x + 18;
            InterfaceButton.loadbg.y = InterfaceButton.RWbtn.y + 3;
            InterfaceButton.loadprogress.x = InterfaceButton.loadbg.x;
            InterfaceButton.loadprogress.y = InterfaceButton.loadbg.y;
            InterfaceButton.playprogress.x = InterfaceButton.loadbg.x;
            InterfaceButton.playprogress.y = InterfaceButton.loadbg.y;
            InterfaceButton.videobarbtn.x = InterfaceButton.playprogress.x + InterfaceButton.playprogress.width - InterfaceButton.videobarbtn.width / 2;
            InterfaceButton.videobarbtn.y = InterfaceButton.loadbg.y - 1;
            soundbg.x = StageWidth - 198;
            soundbg.y = InterfaceButton.playbtn.y;
            InterfaceButton.hornbtn.x = 4;
            InterfaceButton.soundline.x = 12;
            InterfaceButton.soundline.y = 9;
            toolsbg.x = soundbg.x + soundbg.width + 2;
            toolsbg.y = soundbg.y;
            skinbg.x = toolsbg.x + toolsbg.width + 2;
            skinbg.y = toolsbg.y;
            fullbg.x = toolsbg.x + (toolsbg.width + 2)*2;
            fullbg.y = toolsbg.y;
        }
    }

}

此包中还有一个loading.as文件,此loading在前面的随笔中有提到过,可参阅前面的...

tools包

CalculateVideoSize.as

 

View Code
package tools 
{
    import flash.media.Video;
    import VideoControls.GetAndSetStage;
    import VideoInterface.InterfaceButton;
     /* *
     * 负责计算视频大小类
     * @author xiaofeng
     
*/
    public class CalculateVideoSize 
    {
         // 舞台初始宽高
        public static  var stage_width:Number;
        public static  var stage_height:Number;
         // 舞台当前宽高
        private static  var StageWidth:Number;
        private static  var StageHeight:Number;
        public  function CalculateVideoSize() 
        {
        }
        public static  function setvideosize(video:Video, loadvideowidth:Number, loadvideoheight:Number): void
        {
            StageWidth = GetAndSetStage.stages.stageWidth;
            StageHeight = GetAndSetStage.stages.stageHeight - InterfaceButton.ListHeight; // 减去菜单背景高度
             if ((loadvideowidth / loadvideoheight) > (StageWidth / StageHeight))
            {
                video.width = StageWidth;
                video.height = StageWidth / (loadvideowidth / loadvideoheight);
                video.x = (stage_width - StageWidth) / 2;
                video.y = (stage_height - StageHeight) / 2 + Math.abs((StageHeight - video.height) / 2);
            }
             else  if ((loadvideowidth / loadvideoheight) < (StageWidth / StageHeight))
            {
                video.height = StageHeight;
                video.width = StageHeight * (loadvideowidth / loadvideoheight);
                video.x = (stage_width - StageWidth) / 2 + (Math.abs(StageWidth - video.width) / 2);
                video.y = (stage_height - StageHeight) / 2;
            }
             else  if ((loadvideowidth / loadvideoheight) == (StageWidth / StageHeight))
            {
                video.width = StageWidth;
                video.height = StageHeight;
                video.x = (stage_width - StageWidth) / 2;
                video.y = (stage_height - StageHeight) / 2;
            }
        }
    }
}

copyImagExtendTransparent.as

 

View Code
package tools 
{
    import flash.display.BitmapData;
    import flash.display.Sprite;
     /* *
     * 将加载进来带有透明区域的图片进行转换,使其透明区域不响应鼠标事件
     * @author xiaofeng
     
*/
    public class copyImagExtendTransparent 
    {
        public  function copyImagExtendTransparent() 
        {
        }
         /* *
         * 使图片透明区域不响应鼠标事件方法
         
*/
        public static  function changeimages(bit:BitmapData):Sprite
        {
             var _width:uint = bit.width;
             var _height:uint = bit.height;
             var sprite:Sprite= new Sprite();
             for ( var x:uint=0; x<_width; x++)
            {
                 for ( var y:uint=0; y<_height; y++)
                {
                     if (bit.getPixel32(x,y))
                    {
                         var aphaValue:uint = bit.getPixel32(x,y) >> 24 & 0xFF;
                        sprite.graphics.beginFill(bit.getPixel(x,y),aphaValue/255);
                        sprite.graphics.drawRect(x,y,1,1);
                        sprite.graphics.endFill();
                    }
                }
            }
             return sprite;
        }
    }
}

SaveConnection.as

 

View Code
package tools 
{
     /* *
     * 保存视频地址
     * @author xiaofeng
     
*/
    public class SaveConnection 
    {
        private static  var videourl:String;
        public  function SaveConnection() 
        {
        }
        public static  function get url():String
        {
             return videourl;
        }
        public static  function set url(myurl:String): void
        {
            videourl = myurl;
        }
    }
}

VideoTime.as

 

View Code
package tools 
{
    import VideoInterface.InterfaceButton;
     /* *
     * 计算时间
     * @author xiaofeng
     
*/
    public class VideoTime 
    {
        private static  var minute:Number;
        private static  var second:Number;
        private static  var min_str:String;
        private static  var sec_str:String;
        public  function VideoTime() 
        {
        }
        public static  function ComputTime(video_time:Number): void
        {
            minute = Math.floor(video_time / 60);
            second = Math.round(video_time % 60);
             if (minute >= 10)
            {
                min_str = String(minute);
            }
             else
            {
                min_str = "0" + minute;
            }
             if (second >= 10)
            {
                sec_str = String(second);
            }
             else
            {
                sec_str = "0" + second;
            }
            InterfaceButton.conttimestring = min_str + ":" + sec_str;
            InterfaceButton.TimeText.text = InterfaceButton.playtimestring + "/" + InterfaceButton.conttimestring;
            InterfaceButton.TimeText.setTextFormat(InterfaceButton.textformat);
        }
    }
}

VideoControls包

ButtonFOControl.as

 

View Code
package VideoControls 
{
     /* *
     * 各类按钮开关
     * @author xiaofeng
     
*/
    public class ButtonFOControl 
    {
        public static  var stopboo:Boolean =  false; // 判断是否有停止记录
        public static  var btnboo:Boolean =  false; // 判断按钮是否能响应事件
        private static  var Seconds:Number; // 视频快进退秒数
        public static  var processboo:Boolean =  false; // 判断是否显示播放完成界面
        public  function ButtonFOControl() 
        {    
        }
        public static  function get get_set_Seconds():Number
        {
             return Seconds;
        }
        public static  function set get_set_Seconds(s:Number): void
        {
            Seconds = s;
        }
    }
}

Copyright.as

 

View Code
package VideoControls 
{
     /* *
     * 版权声明
     * @author xiaofeng
     
*/
    public class Copyright 
    {
        public static const Version:String = "1.0.0.0";
        public static const Author:String = "xiaofeng";
        public static const Email:String = "[email protected]";
        public static const LinkURL:String = "http://www.cnblogs.com/zhoujunfeng2011";
        public  function Copyright() 
        {
            
        }
    }
}

GetAndSetStage.as

 

View Code
package VideoControls 
{
    import flash.display.Stage;
     /* *
     * ...
     * @author xiaofeng
     
*/
    public class GetAndSetStage 
    {
        private static  var _stage:Stage;
        public  function GetAndSetStage() 
        {
            
        }
        public static  function get stages():Stage
        {
             return _stage;
        }
        public static  function set stages(sg:Stage): void
        {
            _stage = sg;
        }
    }
}

Loaders.as

 

View Code
package VideoControls 
{
    import flash.display.Loader;
     /* *
     * 拓展的Loader类
     * @author xiaofeng
     
*/
    public class Loaders extends Loader
    {
        private  var _name:String;
        public  function Loaders() 
        {
        }
        public  function get names():String
        {
             return _name;
        }
        public  function set names(str:String): void
        {
            _name = str;
        }
    }
}

SkinsManager.as

 

View Code
package VideoControls 
{
    import flash.display.Bitmap;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.IOErrorEvent;
    import flash.net.URLRequest;
    import VideoInterface.InterfaceButton;
    import tools.copyImagExtendTransparent;
    import VideoInterface.InterfaceInitialization;
     /* *
     * ...
     * @author xiaofeng
     
*/
    public class SkinsManager 
    {
        public static  var skincont:Array =  new Array(); // 保存obj
        private static  var colors:uint = 0x008ADD; // 默认为蓝色
        public static  var skinnum: int; // 皮肤数量 
        public static  var skinurl:Array =  new Array(); // 保存皮肤连接地址
        public static  var skinnames:Array =  new Array(); // 保存皮肤图片名字
        public  function SkinsManager()
        {    
        }
         /* *
         * 更换皮肤方法
         
*/
        public static  function changeskins(sk:String): void
        {
             var ReplaceURL:String;
             var pattern:RegExp = /skin\//;
             var LoaderURL:String;
            ReplaceURL = "skin/" + sk + "/";
             for ( var i: int = 0; i < skinurl.length; i++ )
            {
                 var imageLoader:Loaders =  new Loaders();
                imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageCom);
                imageLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, imageIoError);
                LoaderURL = skinurl[i];
                LoaderURL = LoaderURL.replace(pattern, ReplaceURL);
                imageLoader.load( new URLRequest(LoaderURL));
                imageLoader.names = skinnames[i];
            }
        }
        private static  function imageCom(evt:Event): void
        {
             var imageLoader:Loaders = Loaders(evt.target.loader);
             var bitmap:Bitmap = Bitmap(imageLoader.content);
             var sprite:Sprite = copyImagExtendTransparent.changeimages(bitmap.bitmapData);
             switch(imageLoader.names)
            {
                 case "play":
                InterfaceButton.playbtn.removeChildAt(0);
                InterfaceButton.playbtn.addChild(sprite);
                 break;
                 case "puase":
                InterfaceButton.puasebtn.removeChildAt(0);
                InterfaceButton.puasebtn.addChild(sprite);
                 break;
                 case "stop":
                InterfaceButton.stopbtn.removeChildAt(0);
                InterfaceButton.stopbtn.addChild(sprite);
                 break;
                 case "tools":
                InterfaceButton.toolsbtn.removeChildAt(0);
                InterfaceButton.toolsbtn.addChild(sprite);
                 break;
                 case "videobar":
                InterfaceButton.videobarbtn.removeChildAt(0);
                InterfaceButton.videobarbtn.addChild(sprite);
                 break;
                 case "skin":
                InterfaceButton.skinbtn.removeChildAt(0);
                InterfaceButton.skinbtn.addChild(sprite);
                 break;
                 case "horn":
                InterfaceButton.hornbtn.removeChildAt(0);
                InterfaceButton.hornbtn.addChild(sprite);
                 break;
                 case "FF":
                InterfaceButton.FFbtn.removeChildAt(0);
                InterfaceButton.FFbtn.addChild(sprite);
                 break;
                 case "RW":
                InterfaceButton.RWbtn.removeChildAt(0);
                InterfaceButton.RWbtn.addChild(sprite);
                 break;
                 case "Full":
                InterfaceButton.Fullbtn.removeChildAt(0);
                InterfaceButton.Fullbtn.addChild(sprite);
                 break;
            }
            evt.target.removeEventListener(Event.COMPLETE, imageCom);
            evt.target.removeEventListener(IOErrorEvent.IO_ERROR, imageIoError);
            evt.target.loader.unload();
            imageLoader.unload();
            imageLoader =  null;
        }
         // 处理加载流错误
        private static  function imageIoError(evt:IOErrorEvent): void
        {
            trace("加载失败");
        }
        public static  function get getandsetcolors():uint
        {
             return colors;
        }
        public static  function set getandsetcolors(cor:uint): void
        {
            colors = cor;
        }
    }
}

其中还用到了一个缓动类greensock,可去网上下载...

接下来就是Main.as,分两部分贴出

一、

View Code
package 
{
    import flash.display.Loader;
    import flash.display.Sprite;
    import flash.events.ContextMenuEvent;
    import flash.events.KeyboardEvent;
    import flash.external.ExternalInterface;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.geom.Point;
    import flash.geom.Rectangle;
    import flash.text.TextField;
    import flash.text.TextFormat;
    import flash.ui.ContextMenu;
    import flash.ui.ContextMenuItem;
    import flash.ui.Mouse;
    import VideoControls.GetAndSetStage;
    import flash.display.StageScaleMode;
    import flash.display.StageAlign;
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import VideoControls.Loaders;
    import VideoControls.SkinsManager;
    import flash.display.Bitmap;
    import tools.*;
    import flash.events.IOErrorEvent;
    import VideoInterface.InterfaceInitialization;
    import PlayerMedia.PlayerVideo;
    import VideoInterface.InterfaceButton;
    import VideoInterface.Draws;
    import VideoControls.ButtonFOControl;
    import com.greensock.TweenLite;
    import com.greensock.easing.*;
    import flash.utils.setInterval;
    import flash.utils.clearInterval;
    import VideoControls.Copyright;
    import flash.net.navigateToURL;
     /* *
     * 文档类
     * @author xiaofeng
     
*/
    [SWF (width = "600", height = "500", backgroundColor = "0x000000",frameRate = "24")]
    public class Main extends Sprite 
    {
        private  var xml:XML;
        private  var num: int;
        private  var k: int = 0;
        private  var video:PlayerVideo;
        private  var loadnum:Number = 0; // 加载百分比
        private  var playnum:Number = 0; // 播放进度比
        private  var interfaceinitialization:InterfaceInitialization;
        private  var soundbarRange:Rectangle; // 声音滑块拖动范围
        private  var soundbarwidth:Number; // 声音滑块原始宽度
        private  var colors:uint; // 存储颜色值
        private  var countwidth:Number; // 计算出后的宽度
        private  var displayNum:Number = 1; // 接收音量
        private  var soundVolumeDisplayBG:Sprite; // 声音大小显示背景
        private  var SVText:TextField =  new TextField();
        private  var videoBarRange:Rectangle; // 视频滑块可拖动范围
        private  var videoBarEventHalder:Boolean =  true; // 判断是否需要更新视频滑块
        private  var skinbg:Sprite;
        private  var skincont:Sprite =  new Sprite();
        private  var timenum:Number = 0;
        private  var skinsname:String; // 比较
        private  var count: int = 0; // 计数器
        private  var setIntervals:uint;
        public  function Main(): void 
        {
            init();
        }
        private  function init(): void 
        {
             // 修改菜单
            ModifyContextMenu();
             // 设置无缩放模式
            stage.scaleMode = StageScaleMode.NO_SCALE;
            GetAndSetStage.stages =  this.stage;
             // 赋予舞台初始大小
            CalculateVideoSize.stage_width =  this.stage.stageWidth;
            CalculateVideoSize.stage_height =  this.stage.stageHeight - InterfaceButton.ListHeight; // 减去菜单背景高度
             // 加载xml
             var xmlload:URLLoader =  new URLLoader();
            xmlload.addEventListener(Event.COMPLETE, xmlcom);
            xmlload.addEventListener(IOErrorEvent.IO_ERROR, xmlloadError);
            xmlload.load( new URLRequest("config.xml"));
        }
        private  function xmlloadError(evt:IOErrorEvent): void
        {
             var xmlerror:TextField =  new TextField();
            xmlerror.text = "加载配置文件失败";
            xmlerror.textColor = 0xffffff;
             this.addChild(xmlerror);
            xmlerror.x = ( this.stage.stageWidth - xmlerror.width) / 2;
            xmlerror.y = ( this.stage.stageHeight - xmlerror.height) / 2;
        }
         // 修改右键菜单方法
        private  function ModifyContextMenu(): void
        {
             var mycontextmenu:ContextMenu =  new ContextMenu();
             var contextmenuitem1:ContextMenuItem =  new ContextMenuItem("Version:" + Copyright.Version, false, true);
             var contextmenuitem2:ContextMenuItem =  new ContextMenuItem("Author:" + Copyright.Author,  truetrue);
             var contextmenuitem3:ContextMenuItem =  new ContextMenuItem("Email:" + Copyright.Email,  truetrue);
            mycontextmenu.hideBuiltInItems();
            mycontextmenu.customItems.push(contextmenuitem1);
            mycontextmenu.customItems.push(contextmenuitem2);
            mycontextmenu.customItems.push(contextmenuitem3);
            contextmenuitem1.enabled =  false;
            contextmenuitem3.enabled =  false;
             this.contextMenu = mycontextmenu;
            contextmenuitem2.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, selectHalder);
        }
        private  function selectHalder(evt:ContextMenuEvent): void
        {
            navigateToURL( new URLRequest(Copyright.LinkURL), "_blank");
        }
        private  function xmlcom(evt:Event): void
        {
            xml =  new XML(evt.target.data);
            SaveConnection.url = xml.child("flv")[1].@url;
            ButtonFOControl.get_set_Seconds = xml.child("Second")[0].@seconds;
            InterfaceButton.replayImageURL = xml.child("Replay")[0].@ReplayImage;
            num = xml.child("skin").child("icon").length();
            SkinsManager.skinnum = xml.child("Folder").child("skin").length();
            skinbg = Draws.DrawsPromptBox(SkinsManager.getandsetcolors, 0.4, 1, 0xFFFFFF, 0.7, 60, 20 * SkinsManager.skinnum, 6, 6);
             for ( var i: int = 0; i < SkinsManager.skinnum; i++ )
            {
                 var skin:Sprite = Draws.drawroundrects(60, 20, 0, 0, 0, SkinsManager.getandsetcolors, 0.2, false, true);
                 var text:TextField =  new TextField();
                 var names:String = xml.child("Folder").child("skin")[i].@Alias;
                text.textColor = 0xFFFFFF;
                text.text = xml.child("Folder").child("skin")[i].@Alias;
                text.selectable =  false;
                text.mouseEnabled =  false;
                text.width = text.textWidth + 5;
                text.height = text.textHeight + 4;
                skin.addChild(text);
                skincont.addChild(skin);
                skin.y = 20 * i;
                skin.buttonMode =  true;
                skin.addEventListener(MouseEvent.CLICK, skins_click);
            }
             var ReplaceURL:String;
             var pattern:RegExp = /skin\//;
             var LoaderURL:String;
            skinsname = xml.child("Folder").child("skin")[0].@name;
            ReplaceURL = "skin/" + skinsname + "/";
             for ( var j: int = 0; j < num; j++ )
            {
                 var loader:Loaders =  new Loaders();
                loader.contentLoaderInfo.addEventListener(Event.COMPLETE, piccom);
                loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, LoaderError);
                LoaderURL = xml.child("skin").child("icon")[j].@url;
                SkinsManager.skinurl.push(LoaderURL);
                LoaderURL = LoaderURL.replace(pattern, ReplaceURL);
                loader.load( new URLRequest(LoaderURL));
                loader.names = xml.child("skin").child("icon")[j].@name;
                SkinsManager.skinnames.push(xml.child("skin").child("icon")[j].@name);
            }
        }
        private  function LoaderError(evt:IOErrorEvent): void
        {
            trace("加载失败");
            evt.target.removeEventListener(IOErrorEvent.IO_ERROR, LoaderError);
        }
        private  function piccom(evt:Event): void
        {
            k++;
             var loader:Loaders = Loaders(evt.target.loader);
             var bitmap:Bitmap = Bitmap(loader.content);
             var ico:Sprite = copyImagExtendTransparent.changeimages(bitmap.bitmapData);
             var obj:Object = { "names":loader.names, "ico":ico };
            SkinsManager.skincont.push(obj);
            evt.target.removeEventListener(Event.COMPLETE, piccom);
            evt.target.removeEventListener(IOErrorEvent.IO_ERROR, LoaderError);
            evt.target.loader.unload();
            loader.unload();
            loader =  null;
             if (k == num)
            {
                LayoutInterface();
            }
        }
         /* *
         * 布置初始界面按钮对象
         
*/
        private  function LayoutInterface(): void
        {
            interfaceinitialization =  new InterfaceInitialization();
             this.addChild(interfaceinitialization);
            interfaceinitialization.Definedobjects(); // 初始化按钮显示对象
            interfaceinitialization.Custombuttonposition(); // 初始化显示对象在舞台上位
            video =  new PlayerVideo();
             // ReadJavaScript();
            video.playvideo(SaveConnection.url);
             this.addChildAt(video, 0);
            soundbarwidth = InterfaceButton.soundvaluebg.width;
            soundbarRange =  new Rectangle(26.5, 4, 80, 0);
            colors = SkinsManager.getandsetcolors;
             // 绘制声音大小显示背景
            soundVolumeDisplayBG = Draws.DrawsPromptBox(colors, 0.6, 1, 0xFFFFFF, 0.6, 30, 15, 6, 6);
            SVText.text = "100";
            SVText.textColor = 0xFFFFFF;
            SVText.selectable =  false;
            SVText.mouseEnabled =  false;
            SVText.width = SVText.textWidth + 4;
            SVText.height = SVText.textHeight + 2;
            soundVolumeDisplayBG.addChild(SVText);
            SVText.x = 4;
            SVText.y = -2;
            soundVolumeDisplayBG.x = InterfaceButton.soundbar.x - 12;
            soundVolumeDisplayBG.y = InterfaceButton.soundbar.y - 21;
            skinbg.addChild(skincont);
            interfaceinitialization.skinbg.addChild(skinbg);
            skinbg.x = - 20;
            skinbg.y = - 84;
            skinbg.alpha = 0;
            skinbg.visible =  false;
            videoBarRange =  new Rectangle(InterfaceButton.loadbg.x - InterfaceButton.videobarbtn.width / 2, InterfaceButton.videobarbtn.y, InterfaceButton.loadbg.width , 0);
             if (SaveConnection.url !=  null)
            {
                 // 添加逐帧事件
                 this.stage.addEventListener(Event.ENTER_FRAME, EnterFrameHalder);
                 this.stage.addEventListener(MouseEvent.MOUSE_UP, soundbar_up);
                 this.stage.addEventListener(KeyboardEvent.KEY_DOWN, Keyboard_down);
                 this.stage.addEventListener(KeyboardEvent.KEY_UP, Keyboard_up);
                 // -------添加各按钮事件---------//
                 // 添加暂停按钮鼠标点击事件
                InterfaceButton.puasebtn.addEventListener(MouseEvent.CLICK, pause_click);
                 // 添加停止按钮鼠标点击事件
                InterfaceButton.stopbtn.addEventListener(MouseEvent.CLICK, stop_click);
                 // 添加视频快进鼠标点击事件
                InterfaceButton.FFbtn.addEventListener(MouseEvent.CLICK, FF_click);
                 // 添加视频快退鼠标点击事件
                InterfaceButton.RWbtn.addEventListener(MouseEvent.CLICK, RW_click);
                 // 添加声音滑块鼠标按下抬起事件
                InterfaceButton.soundbar.addEventListener(MouseEvent.MOUSE_DOWN, soundbar_down);
                InterfaceButton.soundbar.addEventListener(MouseEvent.MOUSE_UP, soundbar_up);
                 // 添加喇叭鼠标点击事件
                InterfaceButton.hornbtn.addEventListener(MouseEvent.CLICK, horn_click);
                 // 添加工具按钮鼠标点击事件
                InterfaceButton.toolsbtn.addEventListener(MouseEvent.CLICK, tools_click);
                 // 添加皮肤按钮鼠标点击事件
                InterfaceButton.skinbtn.addEventListener(MouseEvent.CLICK, skin_click);
                 // 添加视频进度按钮按下、抬起事件
                InterfaceButton.videobarbtn.addEventListener(MouseEvent.MOUSE_DOWN, videobar_down);
                InterfaceButton.videobarbtn.addEventListener(MouseEvent.MOUSE_UP, videobar_up);
                 // 添加视频进度条鼠标点击事件
                InterfaceButton.loadbg.addEventListener(MouseEvent.CLICK, ProgressBar_click);
                InterfaceButton.loadprogress.addEventListener(MouseEvent.CLICK, ProgressBar_click);
                InterfaceButton.playprogress.addEventListener(MouseEvent.CLICK, ProgressBar_click);
                InterfaceButton.playbtn.addEventListener(MouseEvent.CLICK, play_click);
                 // 添加视频鼠标点击事件
                 // this.stage.addEventListener(MouseEvent.CLICK, stage_click);
            }
             else
            {
                 var ErrorImageURL:String = xml.child("Error")[0].@ErrorImage;
                 var ErrorImage:Loader =  new Loader();
                 var format:TextFormat =  new TextFormat();
                ErrorImage.load( new URLRequest(ErrorImageURL));
                 this.addChildAt(ErrorImage, 0);
                ErrorImage.x =  this.stage.stageWidth / 3;
                ErrorImage.y =  this.stage.stageHeight / 3;
                format.font = "宋体";
                format.size = 20;
                format.color = 0xffffff;
                video.LoadState.text = "抱歉!数据异常,请刷新后再试!";
                video.LoadState.setTextFormat(format);
                video.LoadState.selectable =  false;
                video.LoadState.mouseEnabled =  false;
                 this.addChildAt(video.LoadState,0);
                video.LoadState.x = ErrorImage.x + ErrorImage.width + 70;
                video.LoadState.y = ErrorImage.y + ErrorImage.height + 30;
                video.LoadState.width = video.LoadState.textWidth + 10;
            }
             // 当舞台大小改变后,调整视频大小位置
             this.stage.addEventListener(Event.RESIZE, ResizeHalder);
             // 添加全屏按钮鼠标点击事件
            InterfaceButton.Fullbtn.addEventListener(MouseEvent.CLICK, Full_click);
        }
         /* *
         * 调用外部JS函数,获取视频地址
         
*/
        private  function ReadJavaScript(): void
        {
             // 判断该网页中的Flash是否允许接收JS参数
             if (ExternalInterface.available)
            {
                 try
                {
                     // 对外部JS开放的一个接口
                    ExternalInterface.addCallback("setvideodata", acceptjsurl);
                }
                 catch (e:SecurityError)
                {
                     // 跨域访问的权限错误
                }
                 catch (e:SecurityError)
                {
                     // 无法回调
                }
                 catch (e:Error)
                {
                     // 数据连接失败
                }
                 // 调用外部JS函数
                ExternalInterface.call("sendToActionScript");
            }
        }
         // 响应JS的函数实体
        private  function acceptjsurl(url:String =  null): void
        {
            
            SaveConnection.url = encodeURI(url);
            video.playvideo(SaveConnection.url);
             if (url ==  null && count == 0)
            {
                calculagraphjs();
            }
        }
        private  function calculagraphjs(): void
        {
            setIntervals = setInterval(detectvideourl, 3000);
        }
        private  function detectvideourl(): void
        {
             if (SaveConnection.url ==  null)
            {
                count++;
                ExternalInterface.call("sendToActionScript");
                 if (count == 4)
                {
                    clearInterval(setIntervals);
                }
            }
             else
            {
                clearInterval(setIntervals);
            }
        }

 二、

 

View Code
// 判断用户按下的键盘键值,并作出相应处理
        private  function Keyboard_down(evt:KeyboardEvent): void
        {
             var keycode:String = String(evt.keyCode);
             switch( true)
            {
                 // 按下"↑"键(放大音量)
                 case keycode == "38":
                 if (soundVolumeDisplayBG.parent ==  null)
                {
                    interfaceinitialization.soundbg.addChild(soundVolumeDisplayBG);
                }
                 if (InterfaceButton.soundbar.x < soundbarRange.x + soundbarRange.width - 1)
                {
                    InterfaceButton.soundbar.x += 5;
                    soundbarFunc();
                }
                 break;
                 // 按下"↓"键(减小音量)
                 case keycode == "40":
                 if (soundVolumeDisplayBG.parent ==  null)
                {
                    interfaceinitialization.soundbg.addChild(soundVolumeDisplayBG);
                }
                 if (InterfaceButton.soundbar.x > soundbarRange.x)
                {
                    InterfaceButton.soundbar.x -= 5;
                    soundbarFunc();
                }
                 break;
                 // 按下"←"键(快退)
                 case keycode == "37":
                video.Rewind();
                 break;
                 // 按下"→"键(快进)
                 case keycode == "39":
                video.FastForward();
                 break;
            }
        }
         // 判断用户抬起的键盘键值,并作出相应处理
        private  function Keyboard_up(evt:KeyboardEvent): void
        {
             var keycode:String = String(evt.keyCode);
             switch( true)
            {
                 // 按下空格键(暂停播放或恢复播放)
                 case keycode == "32":
                 if (ButtonFOControl.btnboo)
                {
                    video.pausevideo();
                    ButtonFOControl.btnboo =  false;
                    InterfaceButton.puasebtn.removeEventListener(MouseEvent.CLICK, pause_click);
                     if (InterfaceButton.playbtn.hasEventListener(MouseEvent.CLICK) ==  false)
                    {
                        InterfaceButton.playbtn.addEventListener(MouseEvent.CLICK, play_click);
                    }
                }
                 else
                {
                    video.resumevideo();
                    ButtonFOControl.btnboo =  true;
                    InterfaceButton.playbtn.removeEventListener(MouseEvent.CLICK, play_click);
                    InterfaceButton.puasebtn.addEventListener(MouseEvent.CLICK, pause_click);
                }
                 break;
                 // 按下"↑"键(放大音量)
                 case keycode == "38":
                 if (soundVolumeDisplayBG.parent !=  null)
                {
                    interfaceinitialization.soundbg.removeChild(soundVolumeDisplayBG);
                }
                 break;
                 // 按下"↓"键(减小音量)
                 case keycode == "40":
                 if (soundVolumeDisplayBG.parent !=  null)
                {
                    interfaceinitialization.soundbg.removeChild(soundVolumeDisplayBG);
                }
                 break;
                 // 按下Ctrl+Enter键(全屏)
                 case evt.ctrlKey ==  true && keycode == "13":
                 if (stage.displayState == "normal")
                {
                    stage.displayState = "fullScreen";
                }
                 break;
            }
        }
        private  function ResizeHalder(evt:Event): void
        {
            CalculateVideoSize.setvideosize(video, PlayerVideo.video_width, PlayerVideo.video_height);
            interfaceinitialization.ResetPosition( this.stage.stageWidth,  this.stage.stageHeight);
        }
        private  function play_click(evt:MouseEvent): void
        {
             if (ButtonFOControl.stopboo)
            {
                 if (video.videoprocess !=  null)
                {
                     this.stage.removeChild(video.videoprocess);
                    video.videoprocess =  null;
                }
                 this.removeChild(video);
                video =  new PlayerVideo();
                 this.addChildAt(video, 0);
                video.playvideo(SaveConnection.url);
                ButtonFOControl.stopboo =  false;
                ButtonFOControl.btnboo =  true;
                 this.stage.addEventListener(Event.ENTER_FRAME, EnterFrameHalder);
                InterfaceButton.stopbtn.addEventListener(MouseEvent.CLICK, stop_click);
            }
             else
            {
                video.resumevideo();
                InterfaceButton.playbtn.removeEventListener(MouseEvent.CLICK, play_click);
                InterfaceButton.puasebtn.addEventListener(MouseEvent.CLICK, pause_click);
            }
        }
        private  function pause_click(evt:MouseEvent): void
        {
             if (ButtonFOControl.btnboo)
            {
                video.pausevideo();
                InterfaceButton.puasebtn.removeEventListener(MouseEvent.CLICK, pause_click);
                 if (InterfaceButton.playbtn.hasEventListener(MouseEvent.CLICK) ==  false)
                {
                    InterfaceButton.playbtn.addEventListener(MouseEvent.CLICK, play_click);
                }
            }
        }
        private  function stop_click(evt:MouseEvent): void
        {
            video.stopvideo();
             if (ButtonFOControl.processboo && video.videoprocess !=  null)
            {
                 this.stage.removeChild(video.videoprocess);
                video.videoprocess =  null;
            }
            InterfaceButton.stopbtn.removeEventListener(MouseEvent.CLICK, stop_click);
             this.stage.removeEventListener(Event.ENTER_FRAME, EnterFrameHalder);
            InterfaceButton.playbtn.addEventListener(MouseEvent.CLICK, play_click);
            updateplayer();
        }
         // 逐帧函数
        private  function EnterFrameHalder(evt:Event): void
        {
            updatevideoinfo();
        }
        private  function updatevideoinfo(): void
        {
             // 获取加载百分比
            loadnum = video.loadprogress();
             // 获取播放百分比
            playnum = video.playprogress();
             // 判断是否需要更新加载条
             if (InterfaceButton.loadprogress.width!=InterfaceButton.loadbg.width)
            {
                Draws.drawroundrectsNotreturnvalue(InterfaceButton.loadprogress, loadnum * InterfaceButton.loadbg.width, 6, 4, 0, 0, 0x696969);
            }
             // 判断是否能更新播放进度条以及滑块
             if (PlayerVideo.VideoTime != 0 && InterfaceButton.puasebtn.visible)
            {
                 if (InterfaceButton.videobarbtn.visible ==  false)
                {
                    InterfaceButton.videobarbtn.visible =  true;
                }
                Draws.drawroundrectsNotreturnvalue(InterfaceButton.playprogress, playnum * InterfaceButton.loadbg.width, 6, 4, 0, 0, colors);
                 if (videoBarEventHalder)
                {
                    InterfaceButton.videobarbtn.x = InterfaceButton.playprogress.x + InterfaceButton.playprogress.width - (InterfaceButton.videobarbtn.width / 2);
                }
            }
             // 更新播放时间
            InterfaceButton.playtimestring = video.PlayComputTime();
            InterfaceButton.TimeText.text = InterfaceButton.playtimestring + "/" + InterfaceButton.conttimestring;
            InterfaceButton.TimeText.setTextFormat(InterfaceButton.textformat);
        }
         // 更新播放
        private  function updateplayer(): void
        {
             // 更新按钮状态
            InterfaceButton.puasebtn.visible =  false;
            InterfaceButton.playbtn.visible =  true;
             // 更新加载进度条
            InterfaceButton.loadprogress.graphics.clear();
             // 更新播放进度条
            InterfaceButton.playprogress.graphics.clear();
             // 更新播放进度滑块位置
            InterfaceButton.videobarbtn.x = InterfaceButton.playprogress.x + InterfaceButton.playprogress.width - (InterfaceButton.videobarbtn.width / 2);
             // 更新播放时间
            InterfaceButton.TimeText.text = "00:00/00:00";
            InterfaceButton.TimeText.setTextFormat(InterfaceButton.textformat);
        }
         // 视频快进
        private  function FF_click(evt:MouseEvent): void
        {
            video.FastForward();
        }
         // 视频快退
        private  function RW_click(evt:MouseEvent): void
        {
             if (ButtonFOControl.processboo && video.videoprocess !=  null)
            {
                 this.stage.removeChild(video.videoprocess);
                video.videoprocess =  null;
            }
            video.Rewind();
        }
         // 声音滑块鼠标按下
        private  function soundbar_down(evt:MouseEvent): void
        {
            InterfaceButton.soundbar.startDrag( false, soundbarRange);
             // 添加逐帧事件
            InterfaceButton.soundvaluebg.addEventListener(Event.ENTER_FRAME, soundbarhalder);
            interfaceinitialization.soundbg.addChild(soundVolumeDisplayBG);
        }
        private  function soundbarhalder(evt:Event): void
        {
            soundbarFunc();
        }
        private  function soundbarFunc(): void
        {
             // 计算需绘制的宽度
            countwidth = InterfaceButton.soundbar.x - InterfaceButton.soundvaluebg.x + 4;
             // 重新绘制声音显示条
            Draws.drawroundrectsNotreturnvalue(InterfaceButton.soundvalue, countwidth, 6, 3, 0, 0, colors);
            displayNum = video.DragBarSetSoundVolume(countwidth, soundbarwidth);
            soundVolumeDisplayBG.x = InterfaceButton.soundbar.x - 12;
            soundVolumeDisplayBG.y = InterfaceButton.soundbar.y - 21;
            displayNum = Math.round(displayNum * 100);
            SVText.text = String(displayNum);
            SVText.x = (soundVolumeDisplayBG.width - SVText.textWidth)/2 -3;
        }
         // 声音滑块鼠标抬起
        private  function soundbar_up(evt:MouseEvent): void
        {
             // 停止拖动
            InterfaceButton.soundbar.stopDrag();
             // 移除逐帧事件
            InterfaceButton.soundvaluebg.removeEventListener(Event.ENTER_FRAME, soundbarhalder);
             if (soundVolumeDisplayBG.parent !=  null)
            {
                interfaceinitialization.soundbg.removeChild(soundVolumeDisplayBG);
            }
             if (videoBarEventHalder ==  false)
            {
                video.resumevideo();
                videoBarEventHalder =  true;
            }
        }
         // 点击喇叭静音或恢复原来音量
        private  function horn_click(evt:MouseEvent): void
        {
            video.Mute(soundbarwidth);
        }
         // 点击工具按钮事件响应方法
        private  function tools_click(evt:MouseEvent): void
        {
            
        }
         // 点击皮肤按钮事件响应方法
        private  function skin_click(evt:MouseEvent): void
        {
             if (skinbg.visible ==  false)
            {
                skinbg.visible =  true;
                TweenLite.to(skinbg, 1, { alpha:1, ease:Back.easeInOut } );
            }
             else
            {
                TweenLite.to(skinbg, 1, { alpha:0, ease:Back.easeOut } );
                skinbg.visible =  false;
            }
        }
         // 点击全屏按钮事件响应方法
        private  function Full_click(evt:MouseEvent): void
        {
             switch (stage.displayState)
            {
                 case "normal" :
                    stage.displayState = "fullScreen";
                     break;
                 case "fullScreen" :
                 default :
                    stage.displayState = "normal";
                     break;
            }
        }
        private  function videobar_down(evt:MouseEvent): void
        {
             // video.pausevideo();
            videoBarEventHalder =  false;
            InterfaceButton.videobarbtn.startDrag( false, videoBarRange);
             // 添加音量滑块逐帧事件
            InterfaceButton.videobarbtn.addEventListener(Event.ENTER_FRAME, videoBarHalder);
        }
        private  function videoBarHalder(evt:Event): void
        {
            Draws.drawroundrectsNotreturnvalue(InterfaceButton.playprogress, InterfaceButton.videobarbtn.x - InterfaceButton.loadbg.x + InterfaceButton.videobarbtn.width/2, 6, 4, 0, 0, colors);
        }
        private  function videobar_up(evt:MouseEvent): void
        {
             // 移除音量滑块逐帧事件
            InterfaceButton.videobarbtn.removeEventListener(Event.ENTER_FRAME, videoBarHalder);
            InterfaceButton.videobarbtn.stopDrag();
             // 计算当前视频滑块按钮所在位置时间点
            timenum = PlayerVideo.VideoTime / InterfaceButton.loadbg.width * (InterfaceButton.videobarbtn.x - InterfaceButton.loadbg.x + InterfaceButton.videobarbtn.width / 2);
            video.JumpVideo(timenum);
             // video.resumevideo();
            videoBarEventHalder =  true;
        }
        private  function ProgressBar_click(evt:MouseEvent): void
        {
             if (video.videoprocess !=  null)
            {
                 this.stage.removeChild(video.videoprocess);
                video.videoprocess =  null;
            }
             var point:Point =  new Point(InterfaceButton.loadbg.x, InterfaceButton.loadbg.y);
             var loadbgpoint:Point = InterfaceButton.loadbg.localToGlobal(point);
            timenum = PlayerVideo.VideoTime / InterfaceButton.loadbg.width * ( this.mouseX - loadbgpoint.x);
             if (ButtonFOControl.btnboo ==  false)
            {
                video.resumevideo();
            }
            video.JumpVideo(timenum);
        }
         // 视频点击事件
         /* private function stage_click(evt:MouseEvent):void
        {
            var stageRange:Rectangle = new Rectangle(this.stage.x, this.stage.y, this.stage.stageWidth, this.stage.stageHeight - InterfaceButton.ListHeight);
            if (this.mouseX >= stageRange.x && this.mouseX <= stageRange.x + stageRange.width)
            {
                if (this.mouseY >= stageRange.y && this.mouseY <= stageRange.y + stageRange.height)
                {
                    if (ButtonFOControl.btnboo)
                    {
                        video.pausevideo();
                        InterfaceButton.puasebtn.removeEventListener(MouseEvent.CLICK, pause_click);
                        if (InterfaceButton.playbtn.hasEventListener(MouseEvent.CLICK) == false)
                        {
                            InterfaceButton.playbtn.addEventListener(MouseEvent.CLICK, play_click);
                        }
                    }
                    else
                    {
                        video.resumevideo();
                        InterfaceButton.playbtn.removeEventListener(MouseEvent.CLICK, play_click);
                        InterfaceButton.puasebtn.addEventListener(MouseEvent.CLICK, pause_click);
                    }
                }
            }
        }
*/
         // 更换界面皮肤
        private  function skins_click(evt:MouseEvent): void
        {
             var url:String = evt.target.getChildAt(0).text;
             var skinEnglishName:String;
             for ( var i: int = 0; i < SkinsManager.skinnum; i++ )
            {
                 if (xml.child("Folder").child("skin")[i].@Alias == url)
                {
                    skinEnglishName = xml.child("Folder").child("skin")[i].@name;
                    SkinsManager.getandsetcolors = xml.child("Folder").child("skin")[i].@playprocolor;
                }
            }
             if (skinEnglishName == skinsname)
            {
                TweenLite.to(skinbg, 1, { alpha:0, ease:Back.easeOut } );
                skinbg.visible =  false;
                 return;
            }
            skinsname = skinEnglishName;
            colors = SkinsManager.getandsetcolors;
            video.colors = colors;
             var sb:Sprite = Draws.drawroundrects(6, 10, 6, 0, 0, colors, 0.6);
            InterfaceButton.soundbar.addChild(sb);
            countwidth = InterfaceButton.soundbar.x - InterfaceButton.soundvaluebg.x + 4;
            Draws.drawroundrectsNotreturnvalue(InterfaceButton.soundvalue, countwidth, 6, 3, 0, 0, colors);
            displayNum = video.DragBarSetSoundVolume(countwidth, soundbarwidth);
            SkinsManager.changeskins(skinEnglishName);
             // 取消显示皮肤选择菜单
            TweenLite.to(skinbg, 1, { alpha:0, ease:Back.easeOut } );
            skinbg.visible =  false;
            interfaceinitialization.skinbg.removeChild(skinbg);
             // 重新显示皮肤选择菜单
            skinbg = Draws.DrawsPromptBox(colors, 0.4, 1, 0xFFFFFF, 0.7, 60, 20 * SkinsManager.skinnum, 6, 6);
            skinbg.addChild(skincont);
            interfaceinitialization.skinbg.addChild(skinbg);
            skinbg.x = - 20;
            skinbg.y = - 84;
            skinbg.alpha = 0;
            skinbg.visible =  false;
             // 更新声音大小显示背景
            soundVolumeDisplayBG = Draws.DrawsPromptBox(colors, 0.6, 1, 0xFFFFFF, 0.6, 30, 15, 6, 6);
            soundVolumeDisplayBG.addChild(SVText);
             // 更新显示时间背景以及时间对象
            interfaceinitialization.munebackground.removeChild(interfaceinitialization.timetextbg);
            interfaceinitialization.timetextbg = Draws.drawroundrects(84, InterfaceButton.playbtn.height, 3, 0,0, colors,0.7 , true);
            interfaceinitialization.munebackground.addChild(interfaceinitialization.timetextbg);
            interfaceinitialization.timetextbg.x = InterfaceButton.stopbtn.x + InterfaceButton.stopbtn.width + 2;
            interfaceinitialization.timetextbg.y = InterfaceButton.stopbtn.y;
            interfaceinitialization.timetextbg.addChild(InterfaceButton.TimeText);
        }
    }
}

接下来就是通过JS传参部分:

Default.html

 

View Code
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
< html  xmlns ="http://www.w3.org/1999/xhtml" >
< head >
< meta  http-equiv ="Content-Type"  content ="text/html; charset=utf-8"   />
< title >中国第一高清电影门户网站 </ title >
< script  language ="javascript"  type ="text/javascript" >
function  test(s)
{
    window.open(
" index.html?name= " + s);
}
</ script >
</ head >

< body >
< form  id ="form1"  action ="" >
   < div  style ="height: 286px" >
   < table >
   < tr >
   < td >< input  type ="image"  name ="Image1"  id ="Image1"  src ="Image/psu.jpg"  onclick ="test('游戏展览会上的美女热舞')" /></ td >
   < td >< input  type ="image"  name ="Image2"  id ="Image2"  src ="Image/psuCA6HWRAL.jpg"  onclick ="test('游戏3D美女')"   /></ td >
   < td >< input  type ="image"  name ="Image3"  id ="Image3"  src ="Image/psuCACCILJS.jpg"  onclick ="test('偷拍美女被发现差点被打')" /></ td >
   </ tr >
   < tr >
   < td  align ="center" >游戏展览会上的美女热舞 </ td >
   < td  align ="center" >游戏3D美女 </ td >
   < td  align ="center" >偷拍美女被发现差点被打 </ td >
   </ tr >
   </ table >
   </ div >
</ form >
</ body >
</ html >

index.html

 

View Code
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >
< html  xmlns ="http://www.w3.org/1999/xhtml"  lang ="zh-CN"  xml:lang ="zh-CN" >
     < head >
         < title >VideoPlayer </ title >
         < meta  http-equiv ="Content-Type"  content ="text/html; charset=utf-8"   />
         < style  type ="text/css"  media ="screen" >
        html, body 
{  height : 100% ;  background-color :  #FFFFFF ; }
        body 
{  margin : 0 ;  padding : 0 ;  overflow : scroll ;   }
        #VideoPlayer 
{  margin-left : auto ; margin-right : auto ; border : solid #3c3c3c 1px ; width : 600px ; height : 500px ; top : 50% ; left : 50% ; position : absolute ; margin-left : -300px ; margin-top : -250px ; }
        
</ style >
         < script  language ="JavaScript"  type ="text/javascript" >
            
function  sendToActionScript(Value)
            {
                
var  v  =  window.location.search;
                v 
=  v.replace( ' ?name= ' , '' );            
                
var  u  =   " Flv/ "   +  v  +   " .flv " ;
                window.VideoPlayer.setvideodata(u);
            }
        
</ script >
     </ head >
     < body   >
             < object  classid ="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"  width ="600"  height ="500"  id ="VideoPlayer" >
                 < param  name ="movie"  value ="VideoPlayer.swf"   />
                 < param  name ="quality"  value ="high"   />
                 < param  name ="bgcolor"  value ="#000000"   />
                 < param  name ="play"  value ="true"   />
                 < param  name ="loop"  value ="true"   />
                 < param  name ="wmode"  value ="window"   />
                 < param  name ="scale"  value ="showall"   />
                 < param  name ="menu"  value ="true"   />
                 < param  name ="devicefont"  value ="false"   />
                 < param  name ="salign"  value =""   />
                 < param  name ="allowScriptAccess"  value ="sameDomain"   />
                 < param  name ="allowFullScreen"  value ="true" />
                 <!-- [if !IE]> -->
                 < object  type ="application/x-shockwave-flash"  data ="VideoPlayer.swf"  width ="600"  height ="500" >
                     < param  name ="movie"  value ="VideoPlayer.swf"   />
                     < param  name ="quality"  value ="high"   />
                     < param  name ="bgcolor"  value ="#000000"   />
                     < param  name ="play"  value ="true"   />
                     < param  name ="loop"  value ="true"   />
                     < param  name ="wmode"  value ="window"   />
                     < param  name ="scale"  value ="showall"   />
                     < param  name ="menu"  value ="true"   />
                     < param  name ="devicefont"  value ="false"   />
                     < param  name ="salign"  value =""   />
                     < param  name ="allowScriptAccess"  value ="sameDomain"   />
                     < param  name ="allowFullScreen"  value ="true" />
                 <!-- <![endif] -->
                     < href ="http://www.adobe.com/go/getflash" >
                         < img  src ="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif"  alt ="获得 Adobe Flash Player"   />
                     </ a >
                 <!-- [if !IE]> -->
                 </ object >
                 <!-- <![endif] -->
             </ object >
     </ body >
</ html >

配置文件config.xml

 

View Code
<? xml version="1.0" encoding="utf-8"  ?>
< data >
     < Folder >
         < skin  name ="Defaultskin"  Alias ="默认"  playprocolor ="0X09A3FF" />
         < skin  name ="Redskin"  Alias ="红色激情"  playprocolor ="0xEC0000" />
         < skin  name ="Greenskin"  Alias ="春意昂然"  playprocolor ="0x16D61C" />
         < skin  name ="Purpleskin"  Alias ="紫色魅力"  playprocolor ="0xC00ACF" />
         </ Folder >
     < skin >
         < icon  name ="play"  url ="skin/playbtn.png" />
         < icon  name ="puase"  url ="skin/puasebtn.png" />
         < icon  name ="stop"  url ="skin/stopbtn.png" />
         < icon  name ="tools"  url ="skin/tools.png" />
         < icon  name ="videobar"  url ="skin/videobar.png" />
         < icon  name ="skin"  url ="skin/skin.png" />
         < icon  name ="horn"  url ="skin/horn.png" />
         < icon  name ="FF"  url ="skin/FF.png" />
         < icon  name ="RW"  url ="skin/RW.png" />
         < icon  name ="Full"  url ="skin/Full.png" />
         </ skin >
     < flv  url ="http://url.cn/0pvQ82/?.flv" />
     < flv  url ="Flv/Test.flv" />
     < Error  ErrorImage ="Image/Error.png" />
     < Replay  ReplayImage ="skin/ReplayButton.png" />
     <!-- --!>设置快进退秒数</! -->
     < Second  seconds ="10" />
</ data >

 好了,终于贴完了,程序中可能会存在一些BUG,我已经尽量发现解决了些...不过还有待优化,如果喜欢本博客,就请支持下,谢谢!

最后提供源码下载地址:点击下载(自己准备视频,更改xml中连接或html中JS传入地址)

 

你可能感兴趣的:(as3)