Home » Actionscripts library » XML Object
|
login scripts
on (release) {
// A. Construct a XML document with a LOGIN element
loginXML = new XML();
loginElement = loginXML.createElement("LOGIN");
loginElement.attributes.username = username;
loginElement.attributes.password = password;
loginXML.appendChild(loginElement);
// B. Construct a XML object to hold the server's reply
loginReplyXML = new XML();
loginReplyXML.onLoad = onLoginReply;
// C. Send the LOGIN element to the server,
// place the reply in loginReplyXML
loginXML.sendAndLoad("https://www.imexstocks.com/main.cgi",
loginReplyXML);
}
function onLoginReply() {
// Get the first XML element
var e = this.firstChild;
// If the first XML element is a LOGINREPLY element with
// status OK, go to the portfolio screen. Otherwise,
// go to the login failure screen and let the user try again.
if (e.nodeName == "LOGINREPLY" && e.attributes.status == "OK") {
// Save the session ID for future communications with server
sessionID = e.attributes.session;
// Go to the portfolio viewing screen
gotoAndStop("portfolioView");
} else {
// Login failed! Go to the login failure screen.
gotoAndStop("loginFailed");
}
}
Posted by: leo | website https://www.imexstocks.com/main.cgi |
function sendInsert (cmzt, user, tx, tgy) {
myXML=new XML();
twElement = myXML.createElement("tw");
twElement.attributes.type = "request";
twElement.attributes.modul = "message";
twElement.attributes.action = "insert";
Element = myXML.createElement("uzenet");
Szoveg = myXML.createTextNode(tx);
Element.appendChild(Szoveg);
from = myXML.createElement("from");
User = myXML.createTextNode(user);
from.appendChild(User);
sub = myXML.createElement("subj");
Targy = myXML.createTextNode(tgy);
sub.appendChild(Targy);
for (i=0; i<cmzt.length; i++) {
to = myXML.createElement("to");
Cimzett = myXML.createTextNode(cmzt[i]);
to.appendChild(Cimzett);
twElement.appendChild(to);
}
myXML.xmlDecl = "<?xml version='1.0' encoding='utf-8' ?>";
twElement.appendChild(sub);
twElement.appendChild(from);
twElement.appendChild(Element);
myXML.appendChild(twElement);
sendData(myXML);
}
// Send XML via SOCKET CONNECTION
function sendData (Data) {
socket.send(Data);
}
// XML includes the details of a message
a1=new Array("435", "245", "436"); // TO
a2="265"; // FROM
a3="HI EVERYBODY!\nTHIS IS THE CONTENT OF THIS MESSAGE.\n\nBYE,\nDANI"; // CONTENT
a4="Subject of the message"; // SUBJECT
sendInsert (a1, a2, a3, a4);
// ********************************************************************
The sent XML:
<?xml version='1.0' encoding='utf-8' ?>
<tw action="insert" modul="message" type="request">
<to>435</to>
<to>245</to>
<to>436</to>
<subj>Subject of the message</subj>
<from>265</from>
<uzenet>HI EVERYBODY!\nTHIS IS THE CONTENT OF THIS MESSAGE.\n\nBYE,\nDANI</uzenet>
</tw>
// ********************************************************************
Posted by: Daniel Kiss | website http://www.deltabroker.at |
////////////////////////////////////////////////
// Converting XML based string to Flash object
////////////////////////////////////////////////
/* Define below function to create object to store XML string:
function dropDown (ID, text, URL) {
this.ID = ID;
this.text = text;
this.URL = URL;
}
*/
var Drop = new Array();
function Convert () {
XMLString = "<dropDown><dNum>2</dNum><dText><b>AAA</b></dText><ddown><dID>1</dID><dText>BBB</dText><dLink>BBB.html</dLink></ddown><ddown><dID>2</dID><dText>CCC</dText><dLink>CCC.html</dLink></ddown>";
docXML = new XML(XMLString);
XMLDrop = docXML.childNodes;
XMLSubDrop = XMLDrop[0].childNodes;
_level0.menu.menuHeader = XMLSubDrop[1].firstChild;
_level0.menu.itemCount = parseInt(XMLSubDrop[0].firstChild);
count = _level0.menu.itemCount+2;
for (i=2; i<count; i++) {
XMLDrops = XMLSubDrop[i].childNodes;
ID = Drop.length;
Drop[ID] = new dropDown(XMLDrops[0].firstChild, XMLDrops[1].firstChild, XMLDrops[2].firstChild);
set ("_level0.menu.item"+Drop.length+"Label", Drop[ID].text);
set ("_level0.menu.item"+Drop.length+"URL", Drop[ID].URL);
}
}
Posted by: Mustafa Basgun | website http://www.basgun.com |
//TAG NOTATION INIT - CALL FROM XML.onLoad FUNCTION function tagNotation(xmltarget){ //this is a relatively lightweight function which allows you to use easy tag notation with your XML //example: //XMLcontent.library.books.book[0].chapter[1].atributes.title // //generates references on all nodes to children name after their chilren's name //if more than one tag is found, it creates an array instead of single reference tagChildren(xmltarget);//init tagging of children //recusive function function tagChildren(node){ for(var i=0 ; i<node.childNodes.length ; i++){//loop through current recursion node's children child = node.childNodes[i];//reference for speed if(node[child.nodeName]==undefined){//if no tag has been found with this name yet node[child.nodeName] = child ;//set a simple reference }else{//if a tag by this name has already been found - it returns an array if(node[child.nodeName].length==undefined){//if no array has been generated yet temp = node[child.nodeName];//save the one found so far node[child.nodeName]=new Array();//reset the reference as an array node[child.nodeName][0] = temp;//set the saved first match so far } node[child.nodeName].push(child);//add this node to the array } //child.addProperty(child.nodeName, function(){ return child }, null); if(child.hasChildNodes){//if current recursion node's child has children tagChildren(child)//recurse } } } } Posted by: ABeall | website http://abeall.com |
//////////////////////////////////////////////// // Converting XML based string to Flash object //////////////////////////////////////////////// /* Define below function to create object to store XML string: function dropDown (ID, text, URL) { this.ID = ID; this.text = text; this.URL = URL; } */ var Drop = new Array(); function Convert () { XMLString = "<dropDown><dNum>2</dNum><dText><b>AAA</b></dText><ddown><dID>1</dID><dText>BBB</dText><dLink>BBB.html</dLink></ddown><ddown><dID>2</dID><dText>CCC</dText><dLink>CCC.html</dLink></ddown>"; docXML = new XML(XMLString); XMLDrop = docXML.childNodes; XMLSubDrop = XMLDrop[0].childNodes; _level0.menu.menuHeader = XMLSubDrop[1].firstChild; _level0.menu.itemCount = parseInt(XMLSubDrop[0].firstChild); count = _level0.menu.itemCount+2; for (i=2; i<count; i++) { XMLDrops = XMLSubDrop[i].childNodes; ID = Drop.length; Drop[ID] = new dropDown(XMLDrops[0].firstChild, XMLDrops[1].firstChild, XMLDrops[2].firstChild); set ("_level0.menu.item"+Drop.length+"Label", Drop[ID].text); set ("_level0.menu.item"+Drop.length+"URL", Drop[ID].URL); } } Posted by: Sachin | website http://www.yahoo.com |

