Groups | Blog | Home
all groups > flash actionscript > may 2005 >

flash actionscript : Send mail in Flash using PHP


David Powers
5/23/2005 12:00:00 AM
[quoted text, click to view]

You must use a button. No other way. Can't you remove the image or
highlight it and convert to symbol?

If you want a decent tutorial on creating a Flash contact form with PHP,
go to my site at http://computerbookshelf.com/php5flash/ and follow the
link for the sample chapter. The second half is a fully worked example
of sending an email from an online Flash form. It assumes familiarity
with the Flash interface.

--
David Powers
Author, "Foundation PHP 5 for Flash" (friends of ED)
Co-author "PHP Web Development with DW MX 2004" (Apress)
LuigiL
5/23/2005 12:00:00 AM
Actually, you can turn the image into a mc by hitting F8, choose Movieclip and
name it something like send_mc
Now add a script:
send_mc.onRelease=function(){
//your action here
};
Any mc can behave as a button and you can set states within the movieclip by
adding a layer 'Labels' and inserting keyframes at the positions you want and
call them _up _over and _down (with the underscores)
The hitarea is the movieclip itself.
Coder III
5/23/2005 12:00:00 AM
Thanks for the help.

I actually progressed now to the scripting.

Now I receive an error on the following ActionScript:

function checkForm():Boolean {
var missing:Boolean = false;
error1_txt.text = error2_txt.text = "";
if (name_txt.text == "") {
error1_txt.text = "Please enter a full name!";
missing = true;
}
if (email_txt.text == "") {
error2_txt.text = "Please enter a e-mail address!";
missing = true;
}
return missing ? false : true;
}

The error when checking the script is:
**Error** Symbol=PAGE Contact, layer=Layer 24, frame=25:Line 1: '{' expected
function checkForm():Boolean {

**Error** Symbol=PAGE Contact, layer=Layer 24, frame=25:Line 13: Unexpected
'}' encountered
}

Total ActionScript Errors: 2 Reported Errors: 2

Thanks in advance!!!
David Powers
5/23/2005 12:00:00 AM
[quoted text, click to view]

There's nothing wrong with that part of the script. I've checked it both
visually, and by pasting it into Flash, and running Check Syntax.

The problem lies elsewhere in your script.

[quoted text, click to view]

There's a spare closing curly brace somewhere. You need to go to line 13
and trace back from there.

--
David Powers
Author, "Foundation PHP 5 for Flash" (friends of ED)
Co-author "PHP Web Development with DW MX 2004" (Apress)
Coder III
5/23/2005 12:00:00 AM
Hi again.

I have removed all scripting I could find, I actually reverted back to the
original file before I start to edit it.
Funny enough if I do the script like this (according to me is wrong, the
brackets after "Boolean"):
function checkForm:Boolean() {
var missing:Boolean = false;
error1_txt.text = error2_txt.text = error3_txt.text = "";
}

It's not finding any errors but if I do it like this (which is the correct
declaration):
function checkForm():Boolean {
var missing:Boolean = false;
error1_txt.text = error2_txt.text = error3_txt.text = "";
}

It still gives me the following error:
**Error** Symbol=PAGE Contact, layer=Layer 24, frame=35:Line 1: '{' expected
function checkForm():Boolean {
**Error** Symbol=PAGE Contact, layer=Layer 24, frame=35:Line 4: Unexpected '}'
encountered
}
Total ActionScript Errors: 2 Reported Errors: 2
David Powers
5/23/2005 12:00:00 AM
[quoted text, click to view]

Which version of Flash are you using? That script is written using
ActionScript 2.0. If you're using MX, you'll need to convert it to
ActionScript 1.0 by removing all the parts that have a colon followed by
a datatype, such as :Boolean.

In the case of that function, it's just at the beginning:

function checkForm() {
var missing = false;

--
David Powers
Author, "Foundation PHP 5 for Flash" (friends of ED)
Co-author "PHP Web Development with DW MX 2004" (Apress)
Coder III
5/23/2005 12:00:00 AM
Coder III
5/23/2005 12:00:00 AM
Hi,

I am trying a work around now as I am quite in a hurry to complete this.
I have downloaded a simple flash and php script that just pass a variable from
the Flash to PHP using GetURL();
I noticed in the Flash.swf there is Input Text component with a Var property.
I am unable to find a component with a Var property???

Where is this component or what should I do in order the get a Input text with
a Var property???

Thanks alot!!!
David Powers
5/23/2005 12:00:00 AM
[quoted text, click to view]

I'm not really up to speed on the Flash version 2 components. About a
year ago, I heard a Macromedia official tell a user-group meeting they
are likely to be changed in the next release of Flash, so I stopped
using them. There's nothing wrong with the script in my sample chapter.
It's been tested dozens of times. You can download the sample files from
the friends of ED website and try them out yourself.

As I said before, it's likely to be something else that you've done,
which is causing the problem. You said you're in a hurry. That's often
the cause of tiny mistakes that bring the whole project grinding to a halt.

--
David Powers
Author, "Foundation PHP 5 for Flash" (friends of ED)
Co-author "PHP Web Development with DW MX 2004" (Apress)
Coder III
5/23/2005 12:00:00 AM
Hi there friends,

I am trying to send email in flash using php?
I am totally new to flash and quite familiar with PHP.

There is a Submit (image) on the Contact form. If I try to add actionscript on
the On Release it gives errors and tell me I can not do this must use a button.
The problem is that this web site is a template and I can not change the
structure to my will.

Please help me!!
Coder III
5/23/2005 12:00:00 AM
Sorry, I found the Input Text.

Another question:

I have download a example php and flash script that pass variable from flash
to php which works fine.

But in my Flash document I have place a Input Text and set the Var property to
"fname".
On my submit button I have the code:
on (release) {
getURL("http://localhost/sendmail.php", "_blank", "GET");
}

And my PHP script (sendmail.php) looks like this:
<?php
echo "The variable passed is ".$fname;
?>

When testing the flash and clicking the submit button the PHP scripts executed
but the $fname variable is empty.

What must I look for in order for the variable to be passed properly.
I have a feeling that it's gotta do with Time Line or something like that. My
feeling is that the Submit button is isolated and can not see the Input Text
Variable $fname.

Please help!
sly one
5/23/2005 12:00:00 AM
you need to append your variable to the URL

on (release) {
getURL("http://localhost/sendmail.php?var1=fname", "_blank", "GET");
}

Then in PHP you will have a variable $var1 with a value equal to fname.
David Powers
5/23/2005 12:00:00 AM
[quoted text, click to view]

I have a feeling that you're grasping at straws to find that "magic
solution". Using getURL is not the best way to go about things. The
problem is that you've found something on the web without realizing that
getURL is the kludge that had to be used in the days of Flash 5.

Concentrate on working with LoadVars, and you'll get things right. Also
get out of the habit of putting scripts on buttons. It creates
difficulties for finding other variables, and getting the right path for
everything.

Since you've downloaded my sample chapter, the answer is on pages 73-77.
Give your button an instance name, and put the ActionScript on the main
timeline. What you need is something like this:

submit_btn.onRelease = function() {
send_lv.fname = mytext_input.text;
send_lv.sendAndLoad("http://localhost/sendmail.php?ck=" + new
Date().getTime(), reply_lv);
};
send_lv = new LoadVars();
reply_lv = new LoadVars();
reply_lv.onLoad = function() {
if (this.output != undefined) {
result_txt.text = this.output;
}
};

In the PHP script

<?php
echo 'output='.urlencode('The variable passed is '.$_POST['fname']);
?>

--
David Powers
Author, "Foundation PHP 5 for Flash" (friends of ED)
Co-author "PHP Web Development with DW MX 2004" (Apress)
Coder III
5/31/2005 12:37:06 PM
Hi there,

Me again....

I am no back to the Mail script working with Flash MX and PHP.
With more patience this time and a deadline until Friday.

How do make an button with Static text clickable?
I discovered that all the time my buttons do not have a Hand cursor when mouse
moves over it.
I analyzed other scripts and it looks like this is an indication whether the
button is clickable or not.
I have put a Button component and a Static Text over it with a proper heading.
The I right click and click on "Convert to Symbol".
Then I select "Button" and give a name for ex: "send_button" and click OK. If
I place the new Symbol on the form only the inside of the Text of the Static
Text produces a Hand cursor when mouse over.

Please help with this simple problem....
I have really spend hours to figure this out but to no success. Please help
with step-by-step explanation....

Enjoy your day!
Mex-Mariano
7/13/2005 12:33:37 PM
Coder III,

When you create a button symbol, you can edit it too. Right click on it once
created and edit it. You will see four frames in the timeline of the symbol.
The last one named "Hit", will define where the mouse converts to finger.

The problem I had with text buttons is that not everything is a pixel, so the
mouse does not hits the center of a letter, i.e an "O".
AddThis Social Bookmark Button