Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1737928
  • 博文数量: 358
  • 博客积分: 2180
  • 博客等级: 大尉
  • 技术积分: 1810
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-17 13:47
文章分类

全部博文(358)

文章存档

2016年(17)

2015年(55)

2014年(9)

2013年(67)

2012年(181)

2011年(29)

分类: 系统运维

2011-12-20 13:42:18

=================外部图片或swf加载进度===================

CODE:


//加载外部图片jpg(gif)或影片swf
var url:String = "http://qzgzs.51.net/temp/images/d2.jpg";
var loaderoader = new Loader();
pzztq(loader.contentLoaderInfo);
var dizhi:URLRequest = new URLRequest(url);
loader.load(dizhi);
addChild(loader);
//申明一些变量
var jd:Sprite=new Sprite();
var xzb:Number=stage.stageWidth/2-50;
var yzb:Number=stage.stageHeight/2-1.5;
var jindubj:Sprite=new Sprite();
var jinduk:Sprite=new Sprite();
var jindut:MovieClip=new MovieClip();
var txt:TextField=new TextField();
//进度背景
jindubj.graphics.beginFill(0xcccccc);
jindubj.graphics.drawRect(xzb,yzb,100,3);
jindubj.graphics.endFill();
//进度框
jinduk.graphics.lineStyle(0x000000);
jinduk.graphics.drawRect(xzb,yzb,100,3);
//进度条
jindut.graphics.beginFill(0xff0000);
jindut.graphics.drawRect(0,0,100,3);
jindut.graphics.endFill();
jindut.x=xzb;
jindut.y=yzb;
//设置动态文本
txt.autoSize=TextFieldAutoSize.CENTER;
txt.text="0%";
txt.textColor=0x000000;
txt.selectable=false;
txt.x=stage.stageWidth/2-txt.width/2;
txt.y=stage.stageHeight/2-txt.height/2-10;
//添加子实例
addChild(jd);
addChild(jindubj);
addChild(jinduk);
addChild(jindut);
addChild(txt);
jd.addChild(jindubj);
jd.addChild(jindut);
jd.addChild(txt);
jd.addChild(jinduk);
//配置侦听器函数,IEventDispatcher用于添加或删除事件侦听器
function pzztq(event:IEventDispatcher):void {
event.addEventListener(Event.COMPLETE, jzwchs);
event.addEventListener(ProgressEvent.PROGRESS, jzhs);
}
//加载进度函数
function jzhs(eventrogressEvent):void {
var jindu:Number=event.bytesLoaded /event.bytesTotal;
jindut.scaleX=jindu;
txt.text=uint(jindu*100)+"%";
}
//加载完成函数
function jzwchs(event:Event):void {
removeChild(jd);
loader.width=550;
loader.height=400;
}=================外部图片或swf加载进度===================

CODE:


//加载外部图片jpg(gif)或影片swf
var url:String = "http://qzgzs.51.net/temp/images/d2.jpg";
var loaderoader = new Loader();
pzztq(loader.contentLoaderInfo);
var dizhi:URLRequest = new URLRequest(url);
loader.load(dizhi);
addChild(loader);
//申明一些变量
var jd:Sprite=new Sprite();
var xzb:Number=stage.stageWidth/2-50;
var yzb:Number=stage.stageHeight/2-1.5;
var jindubj:Sprite=new Sprite();
var jinduk:Sprite=new Sprite();
var jindut:MovieClip=new MovieClip();
var txt:TextField=new TextField();
//进度背景
jindubj.graphics.beginFill(0xcccccc);
jindubj.graphics.drawRect(xzb,yzb,100,3);
jindubj.graphics.endFill();
//进度框
jinduk.graphics.lineStyle(0x000000);
jinduk.graphics.drawRect(xzb,yzb,100,3);
//进度条
jindut.graphics.beginFill(0xff0000);
jindut.graphics.drawRect(0,0,100,3);
jindut.graphics.endFill();
jindut.x=xzb;
jindut.y=yzb;
//设置动态文本
txt.autoSize=TextFieldAutoSize.CENTER;
txt.text="0%";
txt.textColor=0x000000;
txt.selectable=false;
txt.x=stage.stageWidth/2-txt.width/2;
txt.y=stage.stageHeight/2-txt.height/2-10;
//添加子实例
addChild(jd);
addChild(jindubj);
addChild(jinduk);
addChild(jindut);
addChild(txt);
jd.addChild(jindubj);
jd.addChild(jindut);
jd.addChild(txt);
jd.addChild(jinduk);
//配置侦听器函数,IEventDispatcher用于添加或删除事件侦听器
function pzztq(event:IEventDispatcher):void {
event.addEventListener(Event.COMPLETE, jzwchs);
event.addEventListener(ProgressEvent.PROGRESS, jzhs);
}
//加载进度函数
function jzhs(eventrogressEvent):void {
var jindu:Number=event.bytesLoaded /event.bytesTotal;
jindut.scaleX=jindu;
txt.text=uint(jindu*100)+"%";
}
//加载完成函数
function jzwchs(event:Event):void {
removeChild(jd);
loader.width=550;
loader.height=400;
}=================外部声音加载与播放进度===================

CODE:


//申明一些变量
var xzb:Number=stage.stageWidth/2-100
var yzb:Number=stage.stageHeight/2-1.5;
var jindubj:Sprite=new Sprite();
var jinduk:Sprite=new Sprite();
var bfjindut:MovieClip=new MovieClip();
var jindut:MovieClip=new MovieClip();
var txt:TextField=new TextField();
//进度背景
jindubj.graphics.beginFill(0xcccccc);
jindubj.graphics.drawRect(xzb,yzb,200,3);
jindubj.graphics.endFill();
//进度框
jinduk.graphics.lineStyle(0x000000);
jinduk.graphics.drawRect(xzb,yzb,200,3);
//进度条
jindut.graphics.beginFill(0xff0000);
jindut.graphics.drawRect(0,0,200,3);
jindut.graphics.endFill();
jindut.x=xzb;
jindut.y=yzb;
//播放进度条
bfjindut.graphics.beginFill(0x00ff00);
bfjindut.graphics.drawRect(0,0,200,3);
bfjindut.graphics.endFill();
bfjindut.x=xzb;
bfjindut.y=yzb;
//设置动态文本
txt.autoSize=TextFieldAutoSize.CENTER;
txt.text="0%";
txt.textColor=0x000000;
txt.selectable=false;
txt.x=stage.stageWidth/2-txt.width/2;
txt.y=stage.stageHeight/2-txt.height/2-10;
//添加子实例
addChild(jindubj);
addChild(jinduk);
addChild(jindut);
addChild(bfjindut);
addChild(txt);
//载入外部声音
var s:Sound = new Sound();
var req:URLRequest = new URLRequest("");
s.load(req);
var shengyincongzhi:SoundChannel=new SoundChannel();
shengyincongzhi=s.play();
//载入进度
s.addEventListener(ProgressEvent.PROGRESS, onLoadProgress);
function onLoadProgress(eventrogressEvent):void {
var jindu:Number=event.bytesLoaded /event.bytesTotal;
jindut.scaleX=jindu;
}
//播放进度
stage.addEventListener(Event.ENTER_FRAME,gx);
function gx(event:Event) {
var zongchangdu=s.length/(s.bytesLoaded/s.bytesTotal);
var bfb=shengyincongzhi.position/zongchangdu;
bfjindut.scaleX=shengyincongzhi.position/zongchangdu;
txt.text="已经播放 :"+Math.round(bfb*100)+"%";
}
阅读(1493) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~