我有这段代码从xml加载我的数据。 我想用这些数据播放一些声音并加载3张图片。
function loadthexml():void {
var numRecs:int = xmlContent.paths.length();
var t_name: String;
var t_sound: String;
var t_age: String;
var t_place: String;
var t_everyday: String;
var t_youwill: String;
var t_pic1: String;
var t_pic2: String;
var t_pic3: String;
var i:int;
for (i=0; i<numRecs; i++) {
t_name=String(xmlContent.paths[i].thename);
txtOutput2.text = t_name;
t_sound=String(xmlContent.paths[i].soundpath);
txtOutput3.text = t_sound;
t_age=String(xmlContent.paths[i].theage);
txtOutput4.text = t_age;
t_place=String(xmlContent.paths[i].theplace);
txtOutput5.text = t_place;
t_everyday=String(xmlContent.paths[i].everyday);
txtOutput6.text = t_everyday;
t_youwill=String(xmlContent.paths[i].youwill);
txtOutput7.text = t_youwill;
t_pic1=String(xmlContent.paths[i].t_pic1);
t_pic2=String(xmlContent.paths[i].t_pic2);
t_pic3=String(xmlContent.paths[i].t_pic3);
pic1holder.addChild(t_pic1);
pic2holder.addChild(t_pic2);
pic3holder.addChild(t_pic3);
}
所以我有3个实例名称为pic1holder的影片剪辑 - picholder - pic3holder但是有 我的代码我无法加载这三张图片。
我哪里错了?
问候!
答案 0 :(得分:0)
好的伙计们,我解决了它:
var myLoader:Loader = new Loader();
var fileRequest:URLRequest = new URLRequest(t_pic1);
myLoader.load(fileRequest);
pic1holder.addChild(myLoader);
var myLoader2:Loader = new Loader();
var fileRequest2:URLRequest = new URLRequest(t_pic2);
myLoader2.load(fileRequest2);
pic2holder.addChild(myLoader2);
var myLoader3:Loader = new Loader();
var fileRequest3:URLRequest = new URLRequest(t_pic3);
myLoader3.load(fileRequest3);
pic3holder.addChild(myLoader3);
谢谢大家的回复!