A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Receive XML data from ASC3 in Asp.Net2 page

Hybrid View

  1. #1
    Junior Member
    Join Date
    Mar 2009
    Posts
    22

    Lightbulb Receive XML data from ASC3 in Asp.Net2 page

    i have an ation script code that send SQL statements to an Asp.Net2 page and here it's:
    package
    {
    import flash.display.MovieClip;
    import flash.xml.*;
    import flash.events.*;
    import flash.net.*;
    public class Script1 extends MovieClip
    {
    public function Script1()
    {
    var SQLXML:String = "";
    SQLXML = createSQLXML("SELECT * FROM [dbo].[Tournaments] ", "Tournaments");
    sendSQLXML("http://localhost/Trial/Default.aspx",SQLXML,handleXMLData);
    }


    public function fixSingleQuotes(strTemp:String):String
    {
    var pattern:RegExp = /\x27/gi;
    return (strTemp.replace(pattern, "'"));
    }


    public function createSQLXML(SQL:String, DataLabel:String):String
    {
    return ("<SQL SQL='" + fixSingleQuotes(SQL) + "' Name='" + DataLabel + "'></SQL>");
    }


    public function sendSQLXML(aspURL:String, SQLXML:String, returnSQLXMLCallback:Function):void
    {
    var myXMLURL:URLRequest = new URLRequest(aspURL);
    var variables:URLVariables = new URLVariables();
    variables.xmlSQL = "<MySQLRequest>" + SQLXML + "</MySQLRequest>";
    myXMLURL.data = variables;
    myXMLURL.method = URLRequestMethod.POST;
    var myLoader:URLLoader = new URLLoader();
    myLoader.addEventListener("complete", returnSQLXMLCallback);
    myLoader.load(myXMLURL);
    }

    public function handleXMLData(evtObj:Event):void
    {
    // Put the returned XML in an XML object.
    var MySQLXML:XML = XML(evtObj.target.data);
    // This will get you to where the data begins.
    var MySQLDataXML:XMLDocument = new XMLDocument();
    MySQLDataXML.ignoreWhite = true;
    MySQLDataXML.parseXML(MySQLXML);
    // Dig deeper for the data.
    var rsNode:Object = MySQLDataXML.firstChild.firstChild;
    // Walk the returned recordset.
    while (rsNode != null)
    {
    var DataNode:Object = rsNode.firstChild;
    while (DataNode != null)
    {
    var FieldNode:Object = DataNode.firstChild;
    // Handle data based on which SQL call this
    // data comes from.
    if (rsNode.nodeName == "Tournaments")
    {
    // Go through the fields returned.
    while (FieldNode != null)
    {
    if (FieldNode.nodeName == "EName")
    {
    //Do something with first field data.
    var strFirstFieldName:String = "EName";
    strFirstFieldName = FieldNode.firstChild.nodeValue;
    trace(strFirstFieldName);
    }
    else if (FieldNode.nodeName == "AName")
    {
    //Do something with second field data.
    var strSecondFieldName:String = "AName";
    strSecondFieldName = FieldNode.firstChild.nodeValue;
    trace(strSecondFieldName);
    }
    else if (FieldNode.nodeName == "AName")
    {
    //Do something with third field data.
    var strThirdFieldName:String = "AName";
    strThirdFieldName = FieldNode.firstChild.nodeValue;
    trace(strThirdFieldName);
    }
    //Move to next field node.
    FieldNode = FieldNode.nextSibling;
    }
    }
    // Move to next data node.
    DataNode = DataNode.nextSibling;
    }
    // Move to next SQL call's recordset.
    rsNode = rsNode.nextSibling;
    }
    }


    }
    }
    and i need the C# code that is written in the Ap.Net page to extract the XML data (SQL statements) and execute the SQL statements on SQLserver2005 and return the result to the actionscript3
    can any one help me plz in sending to me the code
    thanks

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    moved to scripting and backend.
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Junior Member
    Join Date
    Mar 2009
    Posts
    22
    I need a reply to my problem please can any one in this forum help me please???

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center