Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Action Script error

Status
Not open for further replies.

SteveHigh

Technical User
Jan 17, 2007
158
0
0
GB
Hello Ken

A while ago I asked here about how to send an email from a Flash MX 2004 site.

My Flash form aims to 'speak' to an ASP script which I have on the server. I am not too concerned at this stage about displaying a 'Thank you' message in my Flash page or about returning any values from ASP to Flash; I am just focused on acutally getting Flash to 'see' the ASP script and sending the email (the ASP script is written in such a way that a copy of the email goes to the webmaster and another as a copy to the site visitor).

I thought the best way of doing this might be to add some code to the 'Submit' button, but you suggested this was bad practice. Instead, I should give an 'Instance Name' to the 'Submit' button and write the script in the main timeline by which, I take it, you mean the Actions Panel'.

I clicked on the button in the library, and then Edit. Layer 10 seemed to be highlighted and I clicked on each frame. The submit button appeared only in one frame along layer 10 and that was the first frame.

This, then, is what I have at the moment:


However, when I click on Ctrl + Enter, I get the following error msg:

**Error** Scene=Scene 1, layer=Layer 10, frame=1:Line 1: Statement must appear within on handler
submit.onRelease = function():Void{

Total ActionScript Errors: 1 Reported Errors: 1

Do you know what I am doing wrong?

Many thanks.

Steve
 
Hello Ken

Please detail how I move the script to the main timeline. You have suggested this once before, and I was at a loss to understand what you meant.

If it is too cumbersome, I will try to attach the script to the button. Then I use LoadVars, don't I?

Cheers

Steve
 
Main timeline (or root timeline) is the timeline for the Stage. Usually you'll create a new layer and name it "actions", then place all of your scripts in that layer.

(But if you are working on a file not following this practice then you may as well attach your script to a button. It's messy, but if the file is already messy it won't make much difference :)

Kenneth Kawamoto
 
OK Ken

I have highlighted the (submit) button and written the following into the AS Panel:

on(Release) {
loadvariables("flashEmail.asp", "POST");
}

How do I continue now?

Thanks again for your time and trouble.

Steve
 
Your script is wrong. The correct format is:
[tt]loadVariables(url:String, target:Object, [method:String]) : Void[/tt]

But unless you're targeting Flash 5, use LoadVars class instead.

Kenneth Kawamoto
 
Hello Ken

OK, I will try it with this:

on(Release) {
loadvariables("flashEmail.asp", "POST"): Void
}

I take it that the quotation marks ought to be where I have them, and that the URL string refers to my flashEmail.asp file, which sits in the same directory as my .FLA file on the server.

I am not targeting any Flash programme - at least, that was not my aim! All I wish to do is send an email from my Flash site via the flashEmail.asp file.

Cheers

Steve
 
Hello Ken

Nothing at all happens when I try to send an email. I sent the email mto myself, so I know it has not been received.

This is the VB script I am using:

<%
Dim fullname,email,country,message

if Request.Form("Submit") <> "" then

fullname = Request.Form("a1")
email = Request.Form("a2")
country = Request.Form("a3")
message = Request.Form("a4")

Server.Transfer "welcomeFlash.asp"
End if

%>

a1, etc are the names of the four input text boxes (they are placed in the 'instance names' fields) on the stage.

The script seems to work in normal HTML.

Or do you think the problem lies in my FLA file?

Thanks.

Steve
 
What do you mean, 'the 2nd parameter'?

Thanks.

Steve
 
Hello Ken

This is what I have:

on (release) {
loadVariables ("flashEmailTest.asp", 0, "POST"): void
}

I presume the '0' is the second parameter?

I get the following error message:

**Error** Symbol=Symbol 114, layer=Layer 2, frame=1:Line 2: Syntax error.
loadVariables ("flashEmailTest.asp", 0, "POST"): Void

**Error** Symbol=Symbol 114, layer=Layer 2, frame=1:Line 3: Unexpected '}' encountered
}

Total ActionScript Errors: 2 Reported Errors: 2

and if I do this:

on (release) {
loadVariables ("flashEmailTest.asp", "0", "POST"): Void
}


I get the same:


**Error** Symbol=Symbol 114, layer=Layer 2, frame=1:Line 2: Syntax error.
loadVariables ("flashEmailTest.asp", "0", "POST"): Void

**Error** Symbol=Symbol 114, layer=Layer 2, frame=1:Line 3: Unexpected '}' encountered
}

Total ActionScript Errors: 2 Reported Errors: 2

Can you see anything obviously wrong?

Thanks.

Steve

 
You don't need (and can't put) ":Void", which is just telling you the function returns nothing.

But neither "0" nor 0 you're using as 2nd parameter are good. You will need a MovieClip there so that the data returned from your ASP will have somewhere to go.

Have a look at the doc!

Kenneth Kawamoto
 
Hello Ken

If you go here you will see a contact form (email.asp). When the site visitor presses submit a copy of it goes to the site visitor himself (HTML formatted), and a copy goes to the Webmaster. The data is also stored in an MS Access database.

This is what my ASP script does and this is what I would like to happen - again, via my ASP script - from my Flash site.

I do not need it to return anything at all to the Flash site (at some point I will have a 'Thank you, Ken' message for sending the form, but at this stage all I wish to do is get Flash to 'speak' to the ASP file).

In my Flash site, the field forms are called a1 (Name), a2 (Email), a3 (Country), and a4 (Message), so this is the script in my ASP file which Flash needs to 'speak' to:

<%
Dim fullname,email,country,message

if Request.Form("Submit") <> "" then

fullname = Request.Form("a1")
email = Request.Form("a2")
country = Request.Form("a3")
message = Request.Form("a4")

Server.Transfer "welcomeFlash.asp"
End if
%>

At the moment, Flash cannot see this 'flashEmailTest.asp' file on my server. I get no AS error message, when I use:

on (release) {
loadVariables ("flashEmailTest.asp", 0, "POST");
}

and I get no server error message. This, I suspect, is not because the AS is error-free (nor, indeed, because the ASP script is error-free); it is because they cannot 'see' one another.

This makes me think that I have done something wrong at the design stage, so I will just check with you if you don't mind.

a)I have a Movie Clip symbol (114) contact form; within the form I have a symbol button (150). It does not have an ‘instance’ name; if I click once on the button, I CAN paste script into the Actions Panel as the screen shot shows.


b)When I double-click on the ‘submit’ button the timeline changes to this:


In this mode, I am not able to paste anything into the Actions Panel.

Does it seem to you that the ‘Submit’ button has been set up correctly?

Thanks.

Steve
 
Hello Ken

Thank you for your message.

I think I am getting somewhere - slowly.

I have pasted in your script and when not online, Action Script is looking for the flashEmailTest.asp file. Online, I hav completed the 'contact form' I have and clicked 'submit'.

I received an email, meaning that Flash can now see the flashEmailTest.asp file, but the email I received was blank, meaning that the asp file cannot retrieve the form field data I input into it.

Steve
 
Actually, I am trying to send another message to myself, but nothing is coming through. I do not get any server error message which, presumably I would if ther were something wrong with the asp code.

Thanks again.

Steve

 
Hello Ken

I think I have ruled out the 'submit' button as causing a problem.

I clicked on it and inserted the following:

on (release) {

//Goto Webpage Behavior
getURL(" //End Behavior

}

I then uploaded the file, clicked submit and I get taken to the Macromedia site.

Just thought this snippet of information might help.

Cheers

Steve
 
Thanks for that, Ken. I'll take a look at it and try it out.

Cheers

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top