var rooturl_String = new String(_root._url);
var rooturl_Array = rooturl_String.split("/");
var swfFile_Name = new String(rooturl_Array[rooturl_array.length-1]);
var xmlFile_Name = swfFile_Name.slice(-12,-4);
var my_sound:Sound = new Sound();
getXmlBook("../txt/T010000A.xml", xmlFile_Name);
getXmlBook("../../../../studyrecordservlet?lessonName=CATA-DG-HC05-UNIT08",xmlFile_Name);
//启动装载(url,book的type值)
//例(//http://training.alcargo.com.cn/www/kejian/Book2/txt/T010100A.xml,unit1.2)
//------------------------------------------------------------------------------
function getXmlBook(url, name) {
//自写方法(可以写到 一指写文件中)
xmlObj = new XML();
//新建一个节点XML
xmlObj.ignoreWhite = true;
//忽略白空格
xmlObj.load(url);
//读入XML
xmlObj.onLoad = function(success) {
//匿名内隐类用来读XML(出了本方法xmlObj未定义)节约内存在结束时回收内存
var src = "";
if (success) {
//trace("XML加载成功!"); //打印日志
var temp = xmlObj.cloneNode(true);
//深度拷贝到temp(temp在后面会有改变所以不能用var temp=xmlObj)
temp = getMainDoc(temp, "book", name);
//文本找寻(从总节点中找到)book标签type为name的头一个内容
cyclenubmer = getAttribute(temp, "value");
//属性名为value 的值是多少
temp = getMainDoc(temp, "page", "classes");
//
src = getMainDoc(temp, "line", "char");
image = getMainDoc(temp, "line", "image").childNodes;
pageno = getMainDoc(temp, "line", "pageno").childNodes;
prevpage = getMainDoc(temp, "line", "MoviePrev").childNodes;
mepage = getMainDoc(temp, "line", "MovieSelf").childNodes;
nextpage = getMainDoc(temp, "line", "MovieNext").childNodes;
sound = getMainDoc(temp, "line", "MovieSound").childNodes;
titlename = getMainDoc(temp, "line", "TitleName").childNodes;
} else {
//trace("XML加载失败!");
src = "服务器问题请连系工作人员";
}
firstLineTxt = src;
MoviePrev = prevpage;
MovieSelf = mepage;
MovieNext = nextpage;
cycle = cyclenubmer;
if (sound.length>0) {
my_sound.loadSound(sound, false);
}
if (image.length>0) {
pic01.contentPath = image;
}
if (titlename.length>0) {
title_name = titlename;
}
if (cycle>=9) {
flash_name= xmlFile_Name;
}
};
}
my_sound.onLoad = function(bSuccess:Boolean):Void {
if (bSuccess) {
this.start(1, false);
} else {
cycle =1 ;
}
};
my_sound.onSoundComplete = function() {
cycle =1 ;
};
//------------------------------------------------------
function getAttribute(tree, key) {
if (tree.attributes.value.length>0) {
return tree.attributes.value;
} else {
return "";
}
}
function getMainDoc(tree, tager, type) {
var temp1;
for (i in tree.childNodes) {
temp1 = tree.childNodes[i];
if (temp1.localName == tager && temp1.attributes.type == type) {
return temp1;
}
}
return "没找到标签";
}
Movie_prev.onRelease = function():Void {
loadMovie(MoviePrev, "_root");
play();
};
Movie_self.onRelease = function():Void {
loadMovie(MovieSelf, "_root");
play();
};
Movie_next.onRelease = function():Void {
if (cycle>0) {
loadMovie(MovieNext, "_root");
play();
}
};
写得什么玩艺啊
眼尖啊... 联系
服务器问题请连系工作人员