Solved

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

Posted on 2011-02-23
4
577 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
Comment Utility
What does the response page look like ? full XML ?

post an example
0
 

Author Comment

by:toneDigital
Comment Utility
<%@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
Comment Utility

 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
Comment Utility
Thanks!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
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…
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

762 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

13 Experts available now in Live!

Get 1:1 Help Now