PDA

View Full Version : Getting a variable from a combobox?


The Waiter
11-20-2006, 03:11 AM
Hello!!

OK - I am experimenting with the flash 8 components for the first time -
In this case the combobox.

I have got my data showing in the output window of flash -
But I just can't work out how to set the variables/record this data as a variable?!


My as is:

var myListener:Object = new Object();
my_cb.addEventListener("change", myListener);

myListener.change = function(evt){
trace("selected item: " +evt.target.selectedItem.data)
}

The Waiter
11-20-2006, 03:14 AM
I can get the value from my combobox selection to show up in the output window of flash 8, but just want to know how to capture this variable & send it to php?

var myListener:Object = new Object();
my_cb.addEventListener("change", myListener);

myListener.change = function(evt){
trace("selected item: " +evt.target.selectedItem.data)
}

Any help would be great!!! :)

FlashMech
11-20-2006, 03:23 AM
How are you inputing the data? Through AS or by the components parameters?

Maybe if you upload your .fla file it'll be easier. :rolleyes:

The Waiter
11-20-2006, 03:39 AM
I have done it via the component box...

See if you can make sense of this! :)
Thanks

Cota
11-20-2006, 03:46 AM
have you tried?

trace("selected item: " + my_cb.selectedItem.data);

FlashMech
11-20-2006, 03:52 AM
I din't have to make any sense out of it. ;)

It works fine!

What is it that you're trying to achieve anyway?

Cota
11-20-2006, 03:54 AM
Please do not post the same question multiple times.

The Waiter
11-20-2006, 04:00 AM
Hey -

I am basically trying to capture the value of the box selected as a variable - so I can grab it via my php script.
My problem is I'm not sure what to call my variable & where in the actionscript?
My php is like this:

<?

$to = "[email protected]";

$msg .= "Test Value: $_POST[myvariable]\n";

mail($to, $subject, $msg, "From: My web site\nReply-To: $email\n");

?>

Cota
11-20-2006, 04:18 AM
Call the variable whatever you like, make it a _root variable. Something like _root.Cb_entry, then send it to the php file when you send the other stuff.

The Waiter
11-20-2006, 04:24 AM
OK... cool.
But where do I mention my variable in the string of code? ;-/
I am so close - i can smell it.



var myListener:Object = new Object();
combo_cb.addEventListener("change", myListener);

myListener.change = function(evt){
trace("selected item: " +combo_cb.selectedItem.data)

}

Cota
11-20-2006, 04:35 AM
declare your variable on the root timeline
then instead of trace

var myListener:Object = new Object();
combo_cb.addEventListener("change", myListener);

myListener.change = function(evt){
_root.cb_entry = combo_cb.selectedItem.data;

}

The Waiter
11-20-2006, 05:08 AM
I don't seem to be having any luck... maybe been attempting this too long and doing something extra-dopey.

I am declaring my variable as such:

_root.cb_entry = "";



Is this correct or is there a better way?

Cota
11-20-2006, 06:25 AM
attach your FLA..

The Waiter
11-20-2006, 06:44 AM
Cool man. Thanks for being so patient - ;)

The Waiter
11-21-2006, 02:22 AM
Thank you Cota - I stuffed around a bit more & figured it out.
I appreciate your help -


For anyone else out there who wants to do the same thing I have included my files for you to rip apart & apply to your own project (if you are a beginner like me - it might help!)

Now I can get some sleep. ;-/

Cota
11-21-2006, 02:59 AM
Sorry I wasnt able to get back to you in time, but thank you for posting your solution.