Hi I’m trying to get a value from a database and insert it in the “Random Letter Cycling Script” that can be found here
I have created a php-file that gets the data from mysql and I can retreive it in flash and trace it correctly.
How can I get the value from the database to be assigned to the variable “name”.
I have comment the code where I need the variable name to be assigned from the database. The fla is just one frame.
var myxml:XML = new XML();
//Declare XML variable
myxml.ignoreWhite=true;
//ignore any white space in xml file.
myxml.onLoad = function(){
var nodes = this.firstChild.childNodes;
for(i=0;i<nodes.length;i++){
//add items into list component.
mylist.addItem(nodes*.firstChild.nodeValue,i);
name = nodes*.firstChild.nodeValue;
trace (name);
}
}
//load php file.
myxml.load("http://www.mydomain.com/script.php");
This is the code that comes with the “Random cycling letter script”:
onClipEvent (load) {
if (_name == "main") {
trace (name);
//normaly you assign the name varible here like this -> name = "Whatever you want"
//How can I get the value from the database to be assigned to the variable name here?
for (x=0; x<name.length; ++x) {
this.duplicateMovieClip("let"+x, x);
_parent["let"+x]._x += x*15;
_parent["let"+x].endLetter = name.charAt(x);
}
_root.alphabet = "abcdefghijklmnopqrstuvwxyz 1234567890";
_alpha = 0;
} else {
cycle = true;
}
}
onClipEvent (enterFrame) {
if (cycle) {
if (this.letter == endLetter) {
++_root.count;
cycle = false;
} else {
this.letter = _root.alphabet.charAt(random(_root.alphabet.length));
}
}
}
Please help!