Solved

Sending vars from a classic ASP page to Flash using AS3?

Posted on 2011-02-23
4
578 Views
Last Modified: 2012-05-11
Hi All,

I am having a bit of trouble retrieving variables from an ASP page. It returns the entire page whereas I just need the variable strAnswer from the page. Any suggestions? Please help.

Here is my code:

var loader:URLLoader = new URLLoader();
        loader.addEventListener(Event.COMPLETE, onDataSaved);
        loader.dataFormat = URLLoaderDataFormat.VARIABLES;

        var request:URLRequest = new URLRequest("http://" + host + urlPath + "setXML.asp");
        request.method = URLRequestMethod.POST;

        var variables:URLVariables = new URLVariables();
        variables.xmlString = str;
        variables.eltGuid = eltGuid;
        request.data = variables;

        loader.load(request);


    private function onDataSaved(e:Event):void 
    {
        var loader2:URLLoader = URLLoader(e.target);
        loader2.dataFormat = URLLoaderDataFormat.VARIABLES;
        trace(loader2.data.strAnswer);

    }

Open in new window

0
Comment
Question by:toneDigital
  • 2
  • 2
4 Comments
 
LVL 12

Expert Comment

by:scooby_56
ID: 34964924
What does the response page look like ? full XML ?

post an example
0
 

Author Comment

by:toneDigital
ID: 34965101
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<% 

Response.CacheControl = "no-cache" 
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>setASP</title>
</head>

<body>
<%

Dim xmlBlock, strEltGuid, objRQL
xmlBlock = escape(Request.Form("xmlString"))
strEltGuid = Request.Form("eltGuid")

'---------------------------
'Post to RedDot CMS via RQL
'---------------------------

Set objRQL = Server.CreateObject("RDCMSASP.RdPageData")
objRQL.XMLServerClassname = "RDCMSServer.XmlServer"
xmlData = "<IODATA loginguid=" & Chr(34) & Session("LoginGuid") & Chr(34) &  " format=" & Chr(34) & "1" & Chr(34) & " sessionkey=" & Chr(34) & Session("SessionKey") & Chr(34) & "><ELT translationmode='0' extendedinfo='' reddotcacheguid='' action='save' guid='" & strEltGuid & "' pageid='' id='' index='' type='31'>" & xmlBlock & "</ELT></IODATA>"
'Response.Write(xmlBlock)
'Response.Write(strEltGuid)
objRQL.ServerExecuteXML xmlData, rqlError
If rqlError <> "" Then
Response.Write rqlError
Else
strAnswer = "strResponse=Just a test!   How strange. ..."
Response.Write (strAnswer)
'Response.Write "strResponse=Just a test!   How strange. ..."
'Response.Write 	 "Saved successfully."			'"Saved successfully."  							'
End If

'Response.Write "strResponse=Just a test!   How strange. ..."


'------------------
'Be a good citizen
'------------------

Set objRQL = Nothing

%>
</body>
</html>

Open in new window

0
 
LVL 12

Accepted Solution

by:
scooby_56 earned 500 total points
ID: 34967980

 With Page.Response
            .Clear()
            .CacheControl = "no-cache"
            .ContentType = "text/xml" 'use "text/html" if not XML
            .Expires = -1
            .AddHeader("Pragma", "no-cache")
            .Write("<root><row></row></root>")
            .End() ' This should stop the rest of your html markup showing. Alternatively you could remove the markup from the page.
End With

Open in new window



Also take a look at another example here
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/ASP/Q_26660161.html
0
 

Author Comment

by:toneDigital
ID: 34970279
Thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now