PDA

View Full Version : creating checkboxes in a flash form?


kade119
05-16-2007, 05:07 PM
is this possible to creat checkboxes like u do in html, but in flash?

can someone explain how?

dvlnblk
05-16-2007, 06:24 PM
make a small white box with a black outline. Turn it into a movieClip and then go into it. Add a second frame that has the white box with the black outline but on the second frame place an X inside the box. Then navigate to the root of the FLA and give the box an instance name of checkbox0. Then in the AS frame put this:



var myCheckBoxVar:String = "no selection";
checkbox0.onRelease = function():Void{
\\ make the checkbox0 MC go to the X frame
this.gotoAndStop(2);
\\ set some variable to indicate that this checkbox was clicked
myCheckBoxVar = "checkbox0";
}



That is how I would do it. Dvl

kade119
05-16-2007, 07:58 PM
how do you go about doing this in flash? so that the checkboxes submit information to the e-mail, along w/ the rest of the data that is transferred?

is there a way to create this in flash? the checkboxes

jenjenut233
05-16-2007, 08:43 PM
Yes, it is built-in to Flash. Open the Components panel from the Window menu. Expand the UI Components section. Scroll down until you see Checkbox. Drag the Checkbox component onto the stage. You can drag a hundred of them if you want. Then you'll need to set up each checkbox's properties.

Select a checkbox on the stage. Then open the Property panel (if it's not already open at the bottom) and where it says <instance name>, give this checkbox a name. Something like cbAnswerA. Do this for each, so you might end up with cbAnswerA, cbAnswerB, cbAnswerC, and cbAnswerD.

Then for each of them, click on the Parameters tab in the Property panel. The label is the text next to the checkbox, so in my example, cbAnswerA would have a label A, cbAnswerB would have a label B, and so on. Label placement is whether or not you want the label to the left or right of the checkbox and selected means whether or not you already want a checkbox to be selected before anyone chooses anything.

kade119
05-25-2007, 11:30 PM
thanks guys, got that down now

but now .. im using php on my contact form.. do u guys know the php to retrieve the selection they made on the checkbox?

LOLFlash
05-28-2007, 04:00 AM
put all your chechBoxs in move named: menuMc
call function in Submit button

function sendSubmit(){
var myVars:String;
for(i in menuMc){
if(menuMc[i].selected) myVars+= i+"="+menuMc[i].label+"&";
}
var sendVars:LoadVars= new LoadVars();
sendVars.load("http://www.yourwebsite.com/checkSelected.php?"+myVars);
}

kade119
06-06-2007, 01:33 AM
so that retrieves the information and sends it w/ the contact form?

LOLFlash
06-07-2007, 03:07 AM
kade

take a look in forum <-> search for "php loadvars" you can find hundreds ready to go examples haw to send and retrieve data to-from php
on your computer in examples folder you have macromedia example of login form

I gave just one way in case you dont know haw many check boxes on screen If you work with XML feed and boxes created on a fly and server need to save data of user choise

There is not much description you'r giving what you want

Please attach file of your application

kade119
06-07-2007, 06:00 AM
ahhh ... hate when things dont work, so heres what i got, sorry i didnt specify, i got the checkbox created and working to get the response sent to my e-mail... but the whole form doesn't seem to be responding.. so what ya got on this ?

thanks


<?php

if ($_SERVER['REQUEST_METHOD'] == "POST") {




$msg = "$name\n\n";
$msg .= "$message\n\n";
$signs_check = $_POST['signs_check']
$phone_check = $_POST['phone_check']
$mail_check = $_POST['mail_check']
$canvasing_check = $_POST['canvasing_check']
$donation_check = $_POST['donation_check']
$yardsign_check = $_POST['yardsign_check']
$host_check = $_POST['host_check']

$name = $_POST['name'];
$company = $_POST['company'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$comment = $_POST['comment'];

$to= '[email protected]';
$subject = "Website Contact";
$msg .= "Name: $name\n\n";
$msg .= "Company: $company\n\n";
$msg .= "Phone: $phone\n\n";
$msg .= "Email: $email\n\n"

$msg .= "Comment: $comment\n\n";
$headers .= "From: $name <$email>";
mail($to, $subject, $msg);
?>







on (release) {
var nLv:LoadVars = new LoadVars();
nLv.name = name.text;
nLv.company = phone.text;
nLv.phone = email.text;
nLv.email = hear.text;
nLv.comment = comments.text;
nLv.signs_check = signs_check.selected;
nLv.phone_check = phone_check.selected;
nLv.mail_check = mail_check.selected;
nLv.canvasing_check = canvasing_check.selected;
nLv.donation_check = donation_check.selected;
nLv.yardsign_check = yardsign_check.selected;
nLv.host_check = host_check.selected;
nLv.sendAndLoad("form.php",nLv,"POST");
gotoAndPlay (2);

}

LOLFlash
06-07-2007, 02:04 PM
LoadVariablesNum is outdated.

You have a lot more control over the variables your sending and receiving with the php script using sendAndLoad()

Using LoadVariablesNum means
"loadVariablesNum("verzenden.php", 0, "POST");"
Any variables on level 0 will be sent to the php script regardless of wether you need them to be sent or not.
With sendAndLoad you can specifcally declare what variables should be sent.

Here a typical contact form script i use.

butSubmit.onRelease = function() {
//You could do some checking of the forms here to make sure the relevent fields
//are filled
submitContact();
};
function submitContact() {
//define object to hold result
result_lv = new LoadVars();
//Define object to hold vars
cc_lv = new LoadVars();
//Attach vars to object
cc_lv.me_name = txName.text;
cc_lv.me_subject = txSubject.text;
cc_lv.to_email = mcToEmail.txEmail.text;
cc_lv.me_email = txUemail.text;
cc_lv.me_msg = txMessage.text;
//Send vars to script
cc_lv.sendAndLoad(path2php + "contact.php", result_lv, "POST");
result_lv.onLoad = function(success) {
if (success) {
//on the last line of the php script put
// echo "&retval=1&";
if (result_lv.retval.length > 0) {
gotoAndStop(8);
} else {
//incase of error trace what has been sent back
trace("ERROR:" + newline + unescape(result_lv));
}
}
};
}

This for of using sendAndLoad() i use to handle all my flash php request's

Hope it helps


continue..

kade119
06-07-2007, 02:50 PM
what does the "result_lv" do? is that to make sure information was input?

LOLFlash
06-07-2007, 04:58 PM
in falsh:
if(signs_check.selected) cc_lv.signsVar= signs_check.label;
if(phone_check.selected) cc_lv.phoneVar= phone_check.label;



<?php






//you can use
if(!empty($_POST['signsVar'] )) $signs_check = "Signs: ".$_POST['signsVar']."\r\n";
if(!empty($_POST['phoneVar'] )) $phone_check= "Phone: ".$_POST['phoneVar']."\r\n";
//or
$mail_check = "";
if(!empty($_POST['mailVar'] )$mail_check ="Mail: ".$_POST['mailVar']."\r\n";

$canvasing_check = $_POST['canvasing_check']
$donation_check = $_POST['donation_check']
$yardsign_check = $_POST['yardsign_check']
$host_check = $_POST['host_check']

$name = $_POST['name'];
$company = $_POST['company'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$comment = $_POST['comment'];

$to= "[email protected]";
$subject = "Website Contact";
$msg .= "Name: $name\n\n";
$msg .= "Company: $company\n\n";
$msg .= "Phone: $phone\n\n";
$msg .= "Email: $email\n\n"

$msg .= "Comment: $comment\n\n".$signs_check .$phone_check.$canvasing_check .$mail_check /// so on;
$headers .= "From: $name <$email>";
if(mail($to, $subject, $msg)) echo 'msg=Mail sent&to='.$to.'&subject='.$subject;
else echo 'msg= Mail faild, Please try again';
?>

LOLFlash
06-07-2007, 05:01 PM
if (result_lv.msg == "Mail sent") {
gotoAndStop(8);
mx.controls.Alert.show(this.msg+"\n to"+this.to+"\n about"+this.subject,"Thanks")

} else {
//incase of error trace what has been sent back
gotoAndStop(0);

mx.controls.Alert.show(this.msg,"Communication Error")
}

kade119
06-07-2007, 11:58 PM
lolflash whats up man i appreciate you helping me alot... im almost there i think .. just i dont think my php is retrieving the information ..if u would look over exactly what i have .. im about at the point of insanity w/ sometihng small...

butSubmit.onRelease = function() {
//You could do some checking of the forms here to make sure the relevent fields
//are filled
submitContact();
};
function submitContact() {
//define object to hold result
result_lv = new LoadVars();
//Define object to hold vars
cc_lv = new LoadVars();
//Attach vars to object
if(signs_check.selected) cc_lv.signsVar= signs_check.label;
cc_lv.ck_phone = phone_check.label;
cc_lv.ck_mail = mail_check.label;
cc_lv.ck_canvasing = canvasing_check.label;
cc_lv.ck_donation = donation_check.label;
cc_lv.ck_yardsign = yardsign_check.label;
cc_lv.ck_host = host_check.label;
cc_lv.name = name.text;
cc_lv.company = company.text;
cc_lv.phone = phone.text;
cc_lv.email = email.text;
cc_lv.comment = comment.text;
//Send vars to script
cc_lv.sendAndLoad(path2php + "form.php", result_lv, "POST");
result_lv.onLoad = function(success) {
if (success) {
//on the last line of the php script put
// echo "&retval=1&";
if (result_lv.retval.length > 0) {
gotoAndStop(8);
} else {
//incase of error trace what has been sent back
trace("ERROR:" + newline + unescape(result_lv));
}
}
};
}




<?php

$mail_check = "";
if(!empty($_POST['mailVar'] )$mail_check ="Mail: ".$_POST['mailVar']."\r\n";

$signs_check = $_POST['signs_check']
$phone_check = $_POST['phone_check']
$canvasing_check = $_POST['canvasing_check']
$donation_check = $_POST['donation_check']
$yardsign_check = $_POST['yardsign_check']
$host_check = $_POST['host_check']

$name = $_POST['name'];
$company = $_POST['company'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$comment = $_POST['comment'];

$to= "[email protected]";
$subject = "Website Contact";
$msg .= "Name: $name\n\n";
$msg .= "Company: $company\n\n";
$msg .= "Phone: $phone\n\n";
$msg .= "Email: $email\n\n"

$msg .= "Comment: $comment\n\n".$signs_check .$phone_check.$canvasing_check .$mail_check
.$yardsign_check .$host_check .$donation_check
$headers .= "From: $name <$email>";
if(mail($to, $subject, $msg)) echo 'msg=Mail sent&to='.$to.'&subject='.$subject;
else echo 'msg= Mail faild, Please try again';
?>








SOMEONE SAVE ME!!!!!! SAVE ME I SAY!!!!!!!

LOLFlash
06-08-2007, 12:03 AM
or attach your file to post

your button submit is component or Button movieClip?

LOLFlash
06-08-2007, 12:18 AM
small corections

butSubmit.onRelease = function() {
//You could do some checking of the forms here to make sure the relevent fields
//are filled
submitContact();
};
function submitContact() {
//define object to hold result
result_lv = new LoadVars();
//Define object to hold vars
cc_lv = new LoadVars();
//Attach vars to object
if(signs_check.selected) cc_lv.signsVar= signs_check.label;
if(phone_check.selected)cc_lv.phoneVar = phone_check.label;
if(mail_check.selected)cc_lv.mailVar = mail_check.label;
if(canvasing_check.selected)cc_lv.canvasingVar=can vasing_check.label;
if(ck_donation.selected) cc_lv.donationVar= ck_donation.label;
if(ck_yardsign.selected)cc_lv.yardsignVar = yardsign_check.label;
if(host_check.selected)cc_lv.hostVar = host_check.label;
cc_lv.name = name.text;
cc_lv.company = company.text;
cc_lv.phone = phone.text;
cc_lv.email = email.text;
cc_lv.comment = comment.text;
//Send vars to script
cc_lv.sendAndLoad("form.php", result_lv, "POST");
result_lv.onLoad = function(success) {
trace(this.msg)
if (success) {
if (this.msg== "Mail sent") {
trace(this.msg+ " " + this.to +" "+this.subject)
gotoAndStop(8);
} else {
trace(this.msg);
//incase of error trace what has been sent back
gotoAndStop(0);
}
}else trace("Communication Error");
}//onLoad

}//submit


now PHP : 5 more nin

kade119
06-08-2007, 12:27 AM
duddddeeeeeee i need to chant for you

LOLFlash
06-08-2007, 01:00 AM
ypur PHP

<?php

$myChecks="";

if(!empty($_POST['mailVar'] )$myChecks =$myChecks."Mail: ".$_POST['mailVar']."\r\n";
if(!empty($_POST['phoneVar'] )$myChecks =$myChecks."Phone: ".$_POST['phoneVar']."\r\n";
if(!empty($_POST['signsVar'] )$myChecks =$myChecks."Signs: ".$_POST['signsVar']."\r\n";
if(!empty($_POST['canvasingVar'] )$myChecks =$myChecks."Canvasing: ".$_POST['canvasingVar']."\r\n";
if(!empty($_POST['donationVar'] )$myChecks =$myChecks."Donation: ".$_POST['donationVar']."\r\n";
if(!empty($_POST['yardsignVar'] )$myChecks =$myChecks."Yard Sign: ".$_POST['yardsignVar']."\r\n";
if(!empty($_POST['hostVar'] )$myChecks =$myChecks."Host: ".$_POST['hostVar']."\r\n";


$name = $_POST['name'];
$company = $_POST['company'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$comment = $_POST['comment'];

$to= "[email protected]";
$subject = "Website Contact";
$msg .= "Name: $name\n\n";
$msg .= "Company: $company\n\n";
$msg .= "Phone: $phone\n\n";
$msg .= "Email: $email\n\n"

$msg .= "Comment: $comment\n\n".$myChecks;
if(mail($to, $subject, $msg)) echo 'msg=Mail sent&to='.$to.'&subject='.$subject;
else echo 'msg=Mail faild, Please try again';
?>

LOLFlash
06-08-2007, 01:05 AM
sry have no time at all

attach files and I can fix it

kade119
06-08-2007, 01:51 AM
its a button movie clip...

when i click submit it just keeps saying transferring data at the bottom but doesn't do anything.. u want me to attach whole flash movie? and hey the check boxes do not have to be checked.... that is optional to the viewers

kade119
06-08-2007, 02:57 AM
this sux.... u still w/ me lolflash? i never had to struggle so much to figure a small piece of programming out... if anyone can help me out...

thanks

LOLFlash
06-08-2007, 03:38 AM
if your button is component

select button on stage press F9 and enter code
on(click){this._parent.submitContact() }


I dont ask you send all you project

create empty movie, copy and paste all your checkboxes and text inputs (you can change labels) and attach to post

or you want me to do it for you?

kade119
06-08-2007, 03:56 AM
hey man here is my menu, u make it work and ill owe u big ... only thing that needs to verify content is e-mail well not even that really.... if u could just make the thing process the php and send to email

LOLFlash
06-08-2007, 04:10 AM
that hard

I need some time to found out haw they work, gtg
make a new thread ask what properties cheboxes have?

my script doesn't work here

do you mind use macromedia components?

kade119
06-08-2007, 01:37 PM
lol !! ur telling me hard alrlight


thanks for all ur help andd support man , u been great


B UMP anyone know how to do this?

LOLFlash
06-08-2007, 06:13 PM
it works but why you dont want to use regular components

You can change skins, style.

kade119
06-08-2007, 10:57 PM
i would but for some odd damn reason tehy wont work on the document im working on , it only makes blank boxes wehre teh comps are suppose to be
can u send me the working file?

how did u do it anyways

kade119
06-09-2007, 01:55 AM
lolllllllllllllllllllll where u at dudeeeeeeeeeee yo bro?

LOLFlash
06-09-2007, 02:18 AM
coz I can
PLS is missing

kade119
06-09-2007, 02:51 AM
PLS prwettttty please ... ur crazy man... cool though

u play pc games?

kade119
06-09-2007, 03:21 AM
comeon bro, i stressed ont his stupid script all week, help me out

LOLFlash
06-09-2007, 05:33 AM
make sure in your components (right click and choose :edit) in frame 2 and frame 3 instead of set(tempPath,uncheckedValue); you have: tempPath= uncheckedValue;

that all it works

kade119
06-09-2007, 05:33 PM
THIS DUDE IS THE MAN!!!!

what a fighter!

helped until the end !

THANKS lolflash!