Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post

    How to pass Response.Write to Flash

    Hello

    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!

    Steve

  • #2
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    Just set the dynamic text's text property equal to a variable that you'll pass in via flashvars or swfobject. I'd recommend that you'd use swfobject since thats a better way to "embed" your flash movies.
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

  • #3
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    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.
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.

  • #4
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post
    Hello

    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.End
    else
    Response.Write "&output=sent"
    End if
    %>

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

    loadVariables("myfile.asp",this,"POST");

    //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.

    Steve

  • #5
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    Steve
    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.
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.

  • #6
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    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.)

    Code:
    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.
    Code:
    <%= 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.
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

  • #7
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post
    Hello Jeremy and Ralph

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

    http://stevehigham59.7host.com/trial/symbol114Test.html

    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.

    Steve

  • #8
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    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:

    Code:
    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:

    Code:
    var myResponse = "&output=sent&username=" & name
    Response.Write myResponse
    and then you'd have the "name" variable:

    Code:
    status_txt.text = 'Thank You ' + this.username;
    Any use?

  • #9
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post
    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.End
    else
    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:

    http://stevehigham59.7host.com/teddy/teddyTest8.html

    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.

    Steve


  •  

    Posting Permissions

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