0

我有这段代码可以从 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 的电影剪辑,但我的代码无法加载这三张图片。

我哪里错了?

问候!

4

1 回答 1

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);

谢谢大家的回复!

于 2012-11-14T18:38:33.113 回答