stage.scaleMode=StageScaleMode.NO_SCALE; //设置舞台属性不跟随播放器大小而改变
stage.showDefaultContextMenu=false; //屏蔽右键菜单
stage.frameRate=12; //帧频率
var stageW=stage.stageWidth;
var stageH=stage.stageHeight; //取得舞台的宽和高
var loadclip:MovieClip=new MovieClip(); //创建预载动画loadclip
this.addChild(loadclip); //将预载动画loadclip添加到舞台
var txt=new TextField(); //创建文本文件txt
txt.autoSize=TextFieldAutoSize.CENTER; //文本文件自适应大小并且居中显示
txt.text="Johnny portfolio loading...";
txt.textColor=0x000000; //设置文本颜色
txt.selectable=false; //文本设置为不可选
txt.x=stageW/2-txt.width/2;
txt.y=stageH/2-txt.height/2; //设置x,y轴的坐标,使他们居中
loadclip.addChild(txt).name="txt";
//将文本txt添加到loadclip中
var stgb=new Sprite;
stgb.graphics.lineStyle(1,0x000000,1);
stgb.graphics.beginFill(0x3399ff, .5); //采用单色填充, 红色透明50%(0.5)
stgb.graphics.endFill();
stgb.x=stageW/2-stage.width/2;
stgb.y=txt.y+txt.height+5;
loadclip.addChild(stgb);
//绘制进度条底色并且添加到舞台
var stg=new Sprite();
stg.graphics.lineStyle(1, 0x000000, 0.5);
stg.graphics.beginGradientFill(GradientType.LINEAR, [0XFF0000, 0xffff00], [100,100], [0,255]);
//填充渐变色:红到黄
stg.graphics.drawRect(0, 0 ,200, 10);
stg.graphics.endFill();
stg.x=stageW/2-stg.width/2;
stg.y=txt.y+txt.height+5;
loadclip.addChild(stg);
//绘制进度条并且添加到舞台
this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, loading);
this.loaderInfo.addEventListener(Event.COMPLETE, loaded);
//添加进度完成监听器
function loading(eve) {
var loadpre:int=eve.bytesLoaded/eve.bytesTotal*100;
txt.text="Johnny portfolio loading..."+loadpre+"%";
stg.scaleX=loadpre/100;
}
//显示进度条载入百分比
function loaded(eve) {
txt.text="影片载入完毕!";
if (framesLoaded==totalFrames) {
removeChild(this.getChildAt(0));
nextFrame();
}
}
阅读(2238) | 评论(0) | 转发(0) |