PDA

View Full Version : Sending error messages to Flash


SteveH
01-29-2008, 11:59 AM
Hello

I have an online form (in Flash) which I would like to send (via ASP) error messages to. This can be done in Flash's Action Script, but I prefer server messages instead.

When the site visitor completes the online form, he should get error messages back if that form is completed incorrectly.

What is the best way of doing this? Would it be something like this:

<%
Dim ErrorMsg,name,email,business,country,message
dim re, results, i
Dim errorArray(100)
For i = 0 TO 100
errorArray(i) = "black"
Next

fullname = Request.Form("name")
email = Request.Form("email")
business = Request.Form("business")
country = Request.Form("country")
message = Request.Form("message")

ErrorMsg = ""
set re = New RegExp
'Name
re.Pattern = "^[^0-9\/><\.,\\!\^\$\*\+\?@#%&\(\);:\[\]\{\}=""']+$"
re.Global = True
re.IgnoreCase = True
if Not re.Test(fullname) then
errorArray(0) = "red"
ErrorMsg = ErrorMsg & "<center>Please type in your full name</center>"
end if

'Email
re.Pattern = "^\w+@\w+\.\w+"
If Not re.Test(email) Then
errorArray(1) = "red"
ErrorMsg = ErrorMsg & "<center>Please type in a valid email address</center>"
end if

'Business
if Len(business) = 0 then
errorArray(2) = "red"
ErrorMsg = ErrorMsg & "<center>Please type in your area of business</center>"
end if

'Country
if Len(country) = 0 then
errorArray(3) = "red"
ErrorMsg = ErrorMsg & "<center>Please type in the name of your country</center>"
end if

'Message
if Len(message) = 0 then
errorArray(4) = "red"
ErrorMsg = ErrorMsg & "<center>Please type in your message</center>"
End if

' if no errors
If ErrorMsg = "" Then
' go on to next page
End if

%>
<font color="red" face="verdana" size="1"><b><%= ErrorMsg %></b></font>

Many thanks for any advice.

Steve

Spudhead
01-30-2008, 06:05 PM
That validation would certainly seem to run correctly, and it would display the HTML error messages. But that won't pass them as variables back into the Flash movie. Is that what you want?

If it's that bit you're stuck on - the actual getting data into Flash so it can use it, then I'd:
1. Ask this in the Flash forum, not in here.
2. Google it (http://www.google.co.uk/search?q=passing+variables+into+Flash). Depending on what version of Flash you're using - and specifically, whether you're using ActionScript 2 or 3, then there are different methods available.

SteveH
01-31-2008, 02:17 PM
OK, Spudhead, thanks for your post.

At least it looks as if the ASP is OK and that the issue lies on the Flash side of things.

Many thanks.

Steve