Actionscript checkbox

Hi,
I’ve been trying to figure something out, and would appreciate any ideas. What I’d like to do is have a checkbox, that when it is checked it loads a movie into an empty movie clip, and when it is unchecked, it loads a different movie into the empty movie clip.

Also if possible I’d like to find a way to output to a variable whether the same checkbox is checked or not. And send the info from the variable in an email. (I know this is a lot to do)

I’ve had a little look into the checkbox component, but I can’t see a way to differentiate between the checked and unchecked state. :puzzle:

Anyone have any ideas?

Thanks,
Josh

erm context where is the check box?

I assume in the email you section?

I’m trying to create something like if you’ve ever seen a car manufacture’s site, where you can choose features and built your car, eg, add roofracks, towbar, whatever (as an example).

So, I’m trying to have a main image, with the additional car features as external clips that will be loaded into empty movies on the main picture.

So let’s say there is an image of a car, and when the user ticks the roofracks checkbox, it loads the movie clip that contains the roofracks onto the main image of the car. And also when the checkbox is ticked, it creates a variable, so that after the user has added all the features they want, they can hit a “send” button, and it’ll email the variables so I’ll know what the user created.

I hope that makes sense…

Thats easier to understand.

Well there must be a way of detecting the checkbox activity, its in the foggy part of my mind.

http://livedocs.adobe.com/flash/mx2004/main_7_2/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Flash_MX_2004&file=00002120.html

if you were being sensible you may include php.

What section are do you think I should use php for? Just the email function, or something else?

This was a bit slow of me, but I’m thinking why don’t I just use a yes and no button instead of a checkbox?

eg.

roofracks – yes no
When the user clicks yes, it loads a roofrack clip onto the main image, and changes a variable called roofracks or someting to “yes” (which I can send to myself in an email).
When the user clicks no, it loads a blank movie clip, and changes the variable to “no”

Does that sound ok?

(BTW, thanks for the help randomagain) :thumb:

straight from the help docs


var checkboxListener:Object = new Object();
checkboxListener.click = function(evt_obj:Object)
{
	if (evt_obj.target.selected)
	{
		evt_obj.target.label = "Selected!";
		trace("checkbox is selected");
	} else
	{
		evt_obj.target.label = "Unselected!";
		trace("checkbox is deselected");
	}
};
my_ch.addEventListener("click",checkboxListener);

first off, thanks for they replies–appreciate it.

I’ve decided to go with the “yes” “no” buttons, simply because it’s easier at my level of actionscript skill :stuck_out_tongue:

this is my code


var roofracktxt:String = "no";
roofrackyes.onRelease = function() {
 loadMovie("roofrack.swf", "container");
 roofracktxt = "yes";
};
roofrackno.onRelease = function() {
 unloadMovie("container");
 roofracktxt = "no";
 };

I have two buttons, one called “roofrackyes” and one called “roofrackno”

roofrack.swf is the image of the roofrack, and “container” is the empty movie clip on the main image that the roofrack.swf is loaded into.

Does anyone know how I would send the variable “roofracktxt” (and more variables depending on how many options I create) via email using a send button? I’ve looked at POSTing them to a php mail form…but honestly it’s a little over my head–any ideas/help would be appreciated.

well as I said PHP, you need to check it isn’t spam sort of thing

roofRackVar = true/false :stuck_out_tongue:

is better than “yes”/“no”

well as I said PHP, you need to check it isn’t spam sort of thing

sorry, but I don’t understand what that means…

the reason I have the variable as a “yes” or “no” string, is so that it’s in a readable format when the variable is emailed to me…
is there a reason to change that?

Well if you are just asking how to send the data to PHP this should do it…Alter it to your liking of course and the dataIn function is what PHP spits back


var dataIn:LoadVars = new LoadVars();
var dataOut:LoadVars = new LoadVars();

dataIn.onLoad = function()
{

};


sendEmail.onRelease = function()
{
	dataOut.roofracktext = roofracktxt;
	dataOut.sendAndLoad("yourphpfile.php",dataIn,"POST"
};


<?php
$rooftext = $_POST['roofracktext'];
?>

umm, is that code right? I’m getting errors when I paste it…

Error Scene=Scene 1, layer=Layer 1, frame=1:Line 11: ‘)’ or ‘,’ expected

Edit: Figured it out, sorry.

Also, thanks for the help, much appreciated. :slight_smile: I’ll work with this code a bit more and post back with how it goes.

my bad…forgot a right paren


var dataIn:LoadVars = new LoadVars();
var dataOut:LoadVars = new LoadVars();

dataIn.onLoad = function()
{

};


sendEmail.onRelease = function()
{
    dataOut.roofracktext = roofracktxt;
    dataOut.sendAndLoad("yourphpfile.php",dataIn,"POST");
};