happinessclover
08-03-2008, 04:27 PM
var aWords:Array = new Array();
var xmlWords:XML;
loadWords();
function loadWords(){
xmlWords = new XML();
xmlWords.ignoreWhite = true;
xmlWords.load("words.xml");
xmlWords.onLoad = function(success){
if(success) {
for (var i=0; i < this.firstChild.childNodes.length; i++) {
trace ("loaded successfully")
aWords.push(this.firstChild.childNodes[i].firstChild.nodeValue);
}
for (i=0;i<aWords.length;i++) {
// pick a word from the list
var word = aWords[i];
var x = random(600)-300;
var y = random(337)-169;
var z = random(Object.environment.fl*2)-Object.environment.fl;
// create an instance of the SpaceWord object
nombre = "word"+String(depth++);
initialization = {txtword: word, x: x, y: y, z: z};
space.attachMovie("spaceWord", nombre, depth, initialization);
}
}
};
}
words.xml:
<sentence>
<sentence>skylight</sentence>
<sentence>Sunlight</sentence>
<sentence>Moonlight</sentence>
<sentence>light</sentence>
<sentence>Twinlight</sentence>
</sentence>
I tried adding in the xml but the swf can't load out the words in my word.xml however the output can trace loaded successfully which means xml is success in loading
I wanted to load all the words out..
Can anyone please tell me the where's the problem?
Thanks!
i got the source code from this website: http://levitated.net/daily/levTextSpace.html
It have the swf on the website to show what i am trying to do.
Thanks again!
var xmlWords:XML;
loadWords();
function loadWords(){
xmlWords = new XML();
xmlWords.ignoreWhite = true;
xmlWords.load("words.xml");
xmlWords.onLoad = function(success){
if(success) {
for (var i=0; i < this.firstChild.childNodes.length; i++) {
trace ("loaded successfully")
aWords.push(this.firstChild.childNodes[i].firstChild.nodeValue);
}
for (i=0;i<aWords.length;i++) {
// pick a word from the list
var word = aWords[i];
var x = random(600)-300;
var y = random(337)-169;
var z = random(Object.environment.fl*2)-Object.environment.fl;
// create an instance of the SpaceWord object
nombre = "word"+String(depth++);
initialization = {txtword: word, x: x, y: y, z: z};
space.attachMovie("spaceWord", nombre, depth, initialization);
}
}
};
}
words.xml:
<sentence>
<sentence>skylight</sentence>
<sentence>Sunlight</sentence>
<sentence>Moonlight</sentence>
<sentence>light</sentence>
<sentence>Twinlight</sentence>
</sentence>
I tried adding in the xml but the swf can't load out the words in my word.xml however the output can trace loaded successfully which means xml is success in loading
I wanted to load all the words out..
Can anyone please tell me the where's the problem?
Thanks!
i got the source code from this website: http://levitated.net/daily/levTextSpace.html
It have the swf on the website to show what i am trying to do.
Thanks again!