View Full Version : Sending Variables To ASP From Flash
Digitalosophy
July 10th, 2003, 02:38 PM
Jubbas tute was great on PHP and Flash. Let's clear up any question with ASP and Flash, as I have seen a few messages regarding this matter as of late.
Part 1
Sending variables to ASP and printing them
Create a form in flash containing 4 textboxes. Make one multiline.
Variable names should be:
name
email
website
comments
Create a submit button and apply these actions to your timeline
submit.onRelease = function(){
getURL("http://www.delusionalfx.com/sendmail.asp",0,"post");
}
Now your all done with the flash, let's move on to the ASP file.
Save this file as sendmail.asp
What we are doing here is pretty simple. We are requesting the variables values from flash and printing them.
<% @Language=VBScript %>
<%
name = Request.Form("name")
email = Request.Form("email")
website = Request.Form("website")
message = Request.Form("comments")
%>
<%=name%><br>
<%=email%><br>
<%=website%><br>
<%=comments%><br>
"<%=" is short for saying Response.Write
Alrighty there is part one, let's move on to the next section
Digitalosophy
July 10th, 2003, 02:40 PM
Part 2
Sending captured variables to an email
<% @language="VBSCRIPT" %>
<%
Dim myMail, myBody
myBody = "Name: "& request.form("name") & vbcrlf
myBody = myBody & "Email: "& request.form("email") & vbcrlf
myBody = myBody & "Website: "& request.form("website") & vbcrlf
myBody = myBody & "Message: "& vbcrlf & request.form("comments")
Set myMail = CreateObject("CDONTS.NewMail")
myMail.BodyFormat=1
myMail.MailFormat=1
myMail.From=request.form("email")
myMail.To=request.form("email")
myMail.Subject="Flash MX Test Email"
myMail.Body=myBody
myMail.Send
set myMail=nothing
%>
There ya go, sorry I have to run, I will give a full explanation of
this code when I get home
btw. I wrote this for Alleen. I def will edit later!
fantim
July 25th, 2003, 05:37 PM
When are you going to clean this up. I don't understand your last post. Is that PHP script supposed to go in sendmail.asp also?
Digitalosophy
July 26th, 2003, 04:03 AM
that is not a php script, i use the php tags to embed the code.
that is the asp file. what do you need to be cleared up?
ahmed
July 26th, 2003, 04:08 AM
interesting.. :)
you might wanna write this up in a tutorial form so we can have it in the tutorials section if you don't mind :)
Digitalosophy
July 26th, 2003, 01:19 PM
yea that would be cool, that was my orginal thought, let me clean it up a bit
fantim
July 26th, 2003, 02:18 PM
Ok so both of the php tags go in the asp script?
Digitalosophy
July 26th, 2003, 02:33 PM
no copy and paste this, the php tags are here because that is the only way to show code on the FORUM page. if yu don't wrap the code around those tags, the code will try to execute.
copy and paste, save as sendmail.asp
<% @language="VBSCRIPT" %>
<%
Dim myMail, myBody
myBody = "Name: "& request.form("name") & vbcrlf
myBody = myBody & "Email: "& request.form("email") & vbcrlf
myBody = myBody & "Website: "& request.form("website") & vbcrlf
myBody = myBody & "Message: "& vbcrlf & request.form("comments")
Set myMail = CreateObject("CDONTS.NewMail")
myMail.BodyFormat=1
myMail.MailFormat=1
myMail.From=request.form("email")
myMail.To=request.form("email")
myMail.Subject="Flash MX Test Email"
myMail.Body=myBody
myMail.Send
set myMail=nothing
%>
Digitalosophy
July 26th, 2003, 02:34 PM
well i just screwed up this entire thread by not wrapping the code in the php tags
can a mod help please! :)
Digitalosophy
July 26th, 2003, 02:35 PM
here is the code again, wow i can't belivee i screwed this up, grr im so mad, it took me a while to write too... :(
<% @language="VBSCRIPT" %>
<%
Dim myMail, myBody
myBody = "Name: "& request.form("name") & vbcrlf
myBody = myBody & "Email: "& request.form("email") & vbcrlf
myBody = myBody & "Website: "& request.form("website") & vbcrlf
myBody = myBody & "Message: "& vbcrlf & request.form("comments")
Set myMail = CreateObject("CDONTS.NewMail")
myMail.BodyFormat=1
myMail.MailFormat=1
myMail.From=request.form("email")
myMail.To=request.form("email")
myMail.Subject="Flash MX Test Email"
myMail.Body=myBody
myMail.Send
set myMail=nothing
%>
fantim
July 27th, 2003, 02:55 AM
Maybe I'm asking a stupid question (actually I got this feeling that i'm sure I am)
but how do you get this to e-mail this information to you?
gak gak gak
July 31st, 2003, 10:05 AM
myMail.cc=request.form("Your email here")
Sim085
February 17th, 2005, 06:53 AM
Hello, I followed your tutorial (I mean the thread) and everything worked fine! Then I tried sending the data from a frame, and retrieve data from another frame, but this did not work!
Dow you know whether this is possible?
Digitalosophy
February 17th, 2005, 11:27 PM
Well depending on what you want to do...
Add a textbox at frame 5 for example, and in a blank frame on frame 5 add something like this code
myTextBox.text = name+newline+email+newline+website+newline+comment s;
Sim085
February 24th, 2005, 09:38 AM
I am sorry I sent so late, but frankly I had lost all hope that this thing can work! :( but i have decided to give it another go.
I have a flash movie called NewsByEmail.fla. This fla file consists of one layer, and 5 frames. In the first I declared a variable called out_newsByEmail_asp. In the first frame the user enters his e-mail, and press the button submit. In the submit button I have the following code.
// Action Event when the user clicks on the
// submit button to add the e-mail to remote database.
on(release){
// Calling the loadVariablesNum to use the asp file.
loadVariablesNum("NewsByEmail.asp?in_NewsByEmail_asp=" add in_NewsByEmail_asp, 1);
// Going to the frame containing the wait notice.
gotoAndPlay(2);
}
Frame 2 and 3 are just two frames used to know whether the asp file has sent anything back to the flash file. That means that the third frame has NO CODE, and the 3rd frame has the following code:
// Checking if any data is already
// returned from the asp file.
if(out_NewsByEmail_asp == null){
//trace(out_NewsByEmail_asp);
this.gotoAndPlay(2); // looping by going to previous page.
}
// The asp file has alredy returned whether
// the e-mail address was accepted or not.
else{
// Checking the data returned from the asp
// file to know whether the inserted e-mail
// address was accepted or not.
if(out_NewsByEmail_asp=="true"){
this.gotoAndStop(4); // Displaying the success frame.
}
// The insertded e-mail
// address is not accepted.
else{
this.gotoAndStop(5); // Displaying the fail frame.
}
}
The last two frames are displayed according to the result sent back by the asp file. As you can see the logic behind it is very simple. And THIS WORKS FINE when I try it on it's own. However for some reason I am still trying to understand it does not work when I load the NewsByEmail.swf from another movie clip.
Following I placed the code that I change to integrate the asp file to send the data in the flash movie loaded in the container. Note that ' means the whole line is remarked.
' THIS IS ASP CODE NOT PHP.
' Response.Write ("out_NewsByEmail_asp=" & commandExecutedSuccessfully)
Response.Write ("currPage.out_NewsByEmail_asp=" & commandExecutedSuccessfully)
Where currPage is the movie clip I use to load the NewsByEmail swf file in place (ie- in the main movie)
Now I can't understand what is wrong. IMPORTANT TO MENTION: The data is sent correctly from the NewsByEmail.fla to the asp file, but the flas is not recieveing any of the data back (which can be either true or false).
I downloaded several examples. One example was with different frames, and this did not work as well!! the other example worked with one frame, one layer, and worked fine ... I tried changing my whole movie to be with one Frame, and different layers, and it ****ed up!! Sounds Funny but I ashure you it's not!!
So at this point I am pleeding for anyone's help, if what I am doing is not possible please tell me!
thanks you!
ps. I attached the code if you want to give it a look!
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.