techruler.com

Windows Tips
Downloads
Blog
Message Board
Software Reviews
JobFinder
Fun Links
About us
Site Map
Contact
Guestbook
Services
Search
Links
About us

Home

 

 

 

What is XML?

XML is a language similiar to html that is used to hold data so that it can be transfered and used in many formats and programs. For example you could use a xml file to hold all of the information that a flash, director, and html file all use, this allows you to edit just the xml to change the information in the other programs using that file.

Example of xml and what each row is called:

      Names:
<addressBook>     root
  <listing>   child
    <name>jon</name> sibling
    <address>12 rd</address> sibling
  </listing>   child
  <listing>   child
    <name>chris</name> sibling
    <address>45 don street</address> sibling
  </listing>   child
</addressBook>     root

XML and Flash

download files- must have flash mx

In order to combine XML and Flash you need to write and xml file and know some flash actionscripting. Here is the code to call and xml file from flash:


getXML = new XML();
getXML.ignoreWhite = true;
getXML.onLoad = loadXMLFile;
getXML.load("password.xml");

The Flash files that I have created will call a password and username from a xml file and load them into flash. Here is the code that I used:

//created by techruler.com
//this function calls the xml files nodes

function loadXMLFile(){
//checks my xml into pop up window
trace("xml declaration: " + this.xmlDecl);
trace("number of children: " + this.firstChild.childNodes.length);
trace("number of siblings: " + this.firstChild.childNodes[0].childNodes.length);
trace(" ");
//loads xml
root = this.firstChild;
child = this.firstChild.childNodes[0];
siblingOne = root.childNodes[0].childNodes[0].childNodes[0];
siblingTwo = root.childNodes[0].childNodes[0].nextSibling.childNodes[0];
trace("root: " + root.nodeName);
trace("child: " + child.nodeName);
trace("siblingOne: " + siblingOne.nodeValue);
trace("siblingTwo: " + siblingTwo.nodeValue);
//declared what values username and password are
userName = siblingOne.nodeValue;
passWord = siblingTwo.nodeValue;
}

//loads the xml file. This is the standard code for loading an
//xml document

getXML = new XML();
getXML.ignoreWhite = true;
getXML.onLoad = loadXMLFile;
getXML.load("password.xml");
//this is the code for the button and checks if the username and
//password match

myButton.onRelease = function(){
if (userName==userNa && passWord==pass) {
gotoAndPlay("load");
}else { other="you are wrong"}
}
stop();

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Email webmaster: webmaster@techruler.com