flash加载各种外部文件
2018-10-12 14:13
465 查看
加载外部swf到层
onClipEvent (load) {
this.gotoAndstop(1);
}
onClipEvent (enterFrame) {
now = level2.getBytesLoaded()
all = level2.getBytesTotal()
loaded = int(now/all*100);
this.gotoAndStop(loaded);
this.bfb = loaded+"%";
if (now == all) {
_root.gotoAndPlay("begin");
}
}
加载到MC
this.onEnterFrame = function() {
if (this.getBytesLoaded()<this.getBytesTotal()) {
Total = this.getBytesTotal()/1000;
Received = this.getBytesLoaded()/1000;
Percentage = (Received/Total)*100;
loaded = int(Received/Total*100);
percent = loaded+"%";
_root.player.musicper = this.percent;
_root.player.musicbar.gotoAndStop(int(Percentage));
} else {
gotoAndPlay(2);
this.onEnterFrame = null;
}
};
stop();
加载记事本文件
mytxtData = new LoadVars();
mytxtData.onData = function(rw) {
if (rw.indexOf("\r\n")>-1) {
trace("oker ");
}
a_txt.text = replacePunc(rw);
};
function replacePunc(str) {
var tempArray = str.split("\r\n");
var tempstr = new String();
for (var i = 0; i<tempArray.length; i++) {
tempstr += tempArray[i]+newline;
}
return tempstr;
}
System.useCodepage = true;
mytxtData.load("mydata.txt");
加载XML文件
var doc1 = new XML();
//---------------------
doc1.ignoreWhite = true;
doc1.load("data.xml");
doc1.onLoad = function(success) {
if (success) {
e = doc1.firstChild.firstChild;
a = e.attributes.kind;
b = e.childNodes[0].firstChild.nodeValue;
c = e.childNodes[1].firstChild.nodeValue;
d = e.childNodes[2].firstChild.nodeValue;
text1 = a+"----------"+b+"----------"+c+"----------"+d;
} else {
trace("载入失败");
}
};
stop();
直接载入图片
pic = new Array();
for (i; i<9; i++) {
pic[i] = "mypic"+i+".jpg";
loadMovie(pic[i], "mc"+i);
trace(pic[i]);
}
载入MP3音乐(直接)
myMusic = new Sound(_root.mySound);
myMusic.loadSound("song1.mp3", false);
myMusic.setVolume(130);
var playing = false;
preloading = true;
this.onEnterFrame = function() {
mTotal = _root.myMusic.getBytesTotal();
mLoaded = _root.myMusic.getBytesLoaded();
if (preloading == true && mLoaded > 0){
mPercent = Math.round((mLoaded/mTotal)*100);
_root.preloader._visible = true;
_root.preloader.mFiller._xscale = mPercent;
if(mPercent >= 100){
myMusic.start(0,999);
preloading = false;
playing = true;
_root.preloader._visible = false;
delete this.onEnterFrame;
}
}
};
相关文章推荐
- Flash如何加载外部wav文件
- 加载外部文件的各种事件
- flash加载外部swf文件层次问题
- flash调用外部声音文件(加载到场景中)
- Flash加载外部文件多法
- 在flash中加载外部.SWF文件的方法
- Flash中加载外部文件的方法
- 如何加载外部FLASH文件
- 在Flash的AS2中加载外部文件(图片/SWF/文本)的办法
- VC++ 动态创建单个工具条,并加载外部的位图(bmp)文件为工具栏图像
- android使用webview加载flash文件
- 如何让全局常量通过外部文件properties来加载
- Ubuntu下QWebView加载flash 文件
- 把ResourceDictionary保存为文件,从外部xaml文件加载ResourceDictionary
- 动态引入的外部 JS 文件在各浏览器中的加载顺序不一致问题解决
- 动态加载js和css(外部文件)
- 技术分享:. 外部动态加载DEX文件风险浅谈
- js加载器动态加载外部Javascript文件
- Silverlight实用窍门系列:2.Silverlight动态加载外部XML指定地址的WebService---(动态加载外部XML文件中指定的WebService地址)
- JS加载器如何动态加载外部js文件