View Full Version : How to pass Response.Write to Flash

01-30-2008, 01:49 PM

I have an HTML page which displays 'Thank you + name' when a site visitor completes an online form.

ASP takes the site visitor's name from the form and, using Response.Write, displays it as part of the 'thank you' message.

I would like to do this in Flash. I imagine I need to use the same Response.Write statement and send it to a dynamic text box in Flash, but what do I put in the Action Script panel, and what do I put in the ASP script?

All and any asistance will be gratefully appreciated!


01-31-2008, 06:33 AM
Just set the dynamic text's text property equal to a variable that you'll pass in via flashvars or swfobject (http://blog.deconcept.com). I'd recommend that you'd use swfobject since thats a better way to "embed" your flash movies.

01-31-2008, 07:55 AM
I'm not on board with the reasoning behind wanting to display this message in Flash. I love Flash, but it has its place. Its best used when it enhances something that can't otherwise be done or is unstable. So why not just have the message display in HTML? You could spice it up with some JavaScript for those with browsers who have it turned on.

Flash is like food seasoning, its best used with certain foods and only as much as necessary.

01-31-2008, 02:29 PM

Thank you to you both for your replies. I have not heard of swfobject (excuse my naivete!), and would feel more comfortable with the traditional way - at least, for now.

This is what I have in my ASP:

If Err.Number <> 0 then
Response.Write "&output=fail"
Response.Write "&output=sent"
End if

And these are the relevant lines from my Action Script (2):


//when the server responds

this.onData = function() {

if(this.output=='sent') {

I have a dynamic text box with an instance name of status_txt, but if I use:

if(this.output=='sent') {

status_txt = 'Thank You <%= name %>';

} else {

//if not

status_txt = 'Sorry, there is a system error';

I cannot get it to work. The message is sent and received, etc, but Flash does not display the 'Thank you + name' message.

Jeremy, I have taken this straight from an HTML page. The 'thank you + name' message is taken from HTML which returns the name:

<font etc>Thank you <%=name%>, and this displays as Thank you Jeremy (depending on the name input in the name field).

Do you mean I should display it as HTML or in an HTML (non Flash) page?

Many thanks again to you both for your help.


01-31-2008, 06:09 PM
What I'm saying is that if you can print the name on the page without using Flash altogether, you are probably better off. I guess I don't know if your online form is Flash, in which case it would make sense to display the message in Flash. Otherwise, if the form is HTML based, it would be extraneous to bring in Flash to print a name. You didn't mention if the form was Flash based or not, so I just assumed it was not, so let me know if it is.

01-31-2008, 10:07 PM
First, I agree with Jeremy as far as only using Flash if its necessary.

Second, wrap your code with the CODE tag (press the # sign in the message box) to make your post more readable.

Thirdly, you weren't setting the text property of your dynamic text field. There are more properties other than text for the dynamic text object. (_x, _y, _alpha, etc.)

if(this.output=='sent') {

status_txt.text = 'Thank You <%= name %>';

} else {

//if not

status_txt.text = 'Sorry, there is a system error';

Fourth, you should reread the first sentence in my initial post to find out how to pass your ASP variable value into Flash.

<%= name %> //I'm not sure the actionscript interpreter is going to understand this and recognize this as ASP's command to print out the value for name.

02-01-2008, 09:44 AM
Hello Jeremy and Ralph

Yes, the form is Flash based. I have a test link here:


Thanks, Ralph, for pointing out the absence of the text property in my dynamic field. I realised that yesterday and inserted it but, again, the form appears to 'stick' after pressing the submit button. The message is sent to my inbox, but it is still not returning anything to the dynamic field.

Yes, I accept there may be a problem with the <%= name %>,, but even so it would still show the 'thank you' part, wouldn't it, or the 'Sorry, there is a system error' - yet it doesn't.

Incidentally, I have this in quotation marks (""), not inverted commas (''), like this:

status_txt.text = "Sorry, there is a system error";

With the code I have, does Flash know that the dynamic text field is on the same page as the form I have? I'm just trying to think of a reason why it won't work.

Cheers again for your help.


02-05-2008, 07:19 PM
Ok... I think I've got this right. In which case:

Yes there is a problem with using ASP script delimiters in ActionScript, and your Flash file is probably generating an error but not one that would result in any sort of error message being displayed in the browser. Flash is useful like that.

So so stop the error, this:

if(this.output=='sent') {
status_txt.text = 'Thank You <%= name %>';

need to display a FLASH variable. Not an ASP one. Where is the "name" variable in Flash? It's not there. If you amended your ASP file so it passed the "name" variable back to the Flash, then Flash could use it. How about changing the ASP to:

var myResponse = "&output=sent&username=" & name
Response.Write myResponse

and then you'd have the "name" variable:

status_txt.text = 'Thank You ' + this.username;

Any use?

02-06-2008, 01:50 PM
Hello Spudhead

Many thanks again for your post.

I get a server error message using that in ASP:

var myResponse = "&server_mes=ok"&username=" & name

It's an 'Unterminated string constant'.

So I tried it like this:

var myResponse = "&server_mes=ok"&username=" & name"

Got an error to say myResponse was not defined, so did this:

Dim myResponse

myResponse = "&server_mes=ok"&username=" & name"

If Err.Number <> 0 then
Response.Write "&server_mes=fail"
Response.Write myResponse
End if

Error returned as username not defined, so changed it to:

myResponse = "&server_mes=ok"&name=" & name"

The server does not seem to mind this (it shows 'false', and nothing else). When I complete the form and click 'submit' I get a 'Thank you undefined' message. The form sends and I get it in my inbox. It has my own name in the name field as I typed it in the name field (it does not have 'undefined' as Flash showed me when submitting the form), and it is saved to my database, again, with my own name in the database 'name' column.

So, just to summarise.

I get 'false' in my browser when I look at the ASP file;
I have your Action Script in my FLA file as you suggested;
I get an email correctly formatted and inserted into the database;
It shows the name field correctly in the received email and database;
It shows it incorrectly in my status_txt dynamic text box as 'undefined'.

The form is here:


It is somewhat shabby because I have paid little attention to the design. I am mainly concerned with the ASP/AS side of things at the moment - I can take my time with the fun aspects later.

Please let me have your views, Spudhead; I think we're getting there!

Cheers again for all your effort and time.