View Full Version : combo box help
jeff_lemon
01-15-2006, 08:21 PM
Hi,
I need it so that when a user selects a number from a combo box (size) then numbers in other text boxes change, heres the code I have done so far:
{
if (size.component == 10)
loc.text = "London";
diameter.text=90.93;
depth.text=18.19;
deaths.text=10203;
remainingpopulation.text=50;
if (size.component == 20)
loc.text = "London";
diameter.text=90.93;
depth.text=18.19;
deaths.text=10333;
remainingpopulation.text=50;
}
The thing is whatever number I put in it always comes up with the data from the '20' size option.
Any ideas?
Thanks
flashead
01-15-2006, 08:25 PM
Syntax is off:
if (size.component == 10)
{
loc.text = "London";
diameter.text=90.93;
depth.text=18.19;
deaths.text=10203;
remainingpopulation.text=50;
}
if (size.component == 20)
{
loc.text = "London";
diameter.text=90.93;
depth.text=18.19;
deaths.text=10333;
remainingpopulation.text=50;
}
jeff_lemon
01-15-2006, 08:29 PM
what do you mean syntax is off......im rubish at actionscript please explain to me basically
jeff_lemon
01-15-2006, 08:33 PM
ive entered in teh code you put and now nothing comes up in the text boxes...
flashead
01-15-2006, 08:37 PM
Where's the rest of your code?
the code you posted started and ended in {}, but had now actual function name or object name.
i.e. a proper function definition looks like:
function comboBoxChange()
{
if (size.component == 10)
{
loc.text = "London";
diameter.text=90.93;
depth.text=18.19;
deaths.text=10203;
remainingpopulation.text=50;
}
if (size.component == 20)
{
loc.text = "London";
diameter.text=90.93;
depth.text=18.19;
deaths.text=10333;
remainingpopulation.text=50;
}
}
so am I to assume this code sits in your combobox's changeHandler?
jeff_lemon
01-15-2006, 08:39 PM
ok ive played with it and the numbers now come up but now only for the number 10, when i enter 20 in the combo box the figures for 10 still come up, heres the code:
stop()
instanceName.onEnterFrame
if (size.text == 10)
{
loc.text = "London";
diameter.text=90.93;
depth.text=18.19;
deaths.text=10203;
remainingpopulation.text=50;
}
if (size.text == 20)
{
loc.text = "London";
diameter.text=90.93;
depth.text=18.19;
deaths.text=10333;
remainingpopulation.text=50;
}
flashead
01-15-2006, 08:43 PM
that's it? is that EXACTLY as it appears in your file??
How are you handling the change on your comboBox?
that line with the instanceName.onEnterFrame isn't doing anything right now as that's not proper syntax.
For future ref, you have to declare the onEnterFrame as a function like:
instanceName.onEnterFrame = function()
{
// code here will get called every frame...
};
But you also don't even need an onEnterFrame to handle a comboBox change.
since your last post I've noticed this line:
if (size.component == 10)
changed to:
if (size.text == 10)
What are you trying to get? the value of the selected item in the combo box?
jeff_lemon
01-15-2006, 08:44 PM
i didnt put it in teh combo box code as I need it for when a frame is entered
jeff_lemon
01-15-2006, 08:45 PM
thats is how it appears in my file...
How are you handling the change on your comboBox?
I dont know what that is...im a novice
jeff_lemon
01-15-2006, 08:51 PM
what im trying to do is this:
when a user enters a number in the combo box the numbers will change in other boxes, the numbers in other boxes relate to what the user enters.
and I want this to happen when a frame is entered
flashead
01-15-2006, 08:54 PM
i didnt put it in teh combo box code as I need it for when a frame is entered
??? I'm lost there.
Are you using Flash 6 or Flash 7 components? I'll set up a small example file of how to handle CB changes.
jeff_lemon
01-15-2006, 09:07 PM
i have no idea what cb changes are.....im just a beginner
i want the values to be entered in my text boxes based on whatevers in teh combo box when frame 71 is entered
flashead
01-15-2006, 09:12 PM
Ok stay with me now, we're talking about ComboBoxes so:
CB changes = ComboBox changes ;)
Now, you still never answered my version question, 6 or 7 so I'm posting a 6 which should work for anything newer too.
jeff_lemon
01-15-2006, 09:14 PM
i dunno, 6 or 7, have no idea....im using flash mx tho...any help?
flashead
01-15-2006, 09:19 PM
MX = 6 ;)
The file I've posted should help some. Although it may all look like gibrish to you too, I'd guess you're jumping in a little deep based on your AS knowledge.
Good luck.
jeff_lemon
01-15-2006, 09:32 PM
I kinda get what youve done...so I can copy and paste it into mine? But I need it so that when frame 71 is entered the boxes are filled in, as they need to be filled in after an animation
flashead
01-15-2006, 09:40 PM
so I can copy and paste it into mine?
You can try but I'm not guaranteeing anything. The file I posted was just an example. If scopes get changed it probably won't work.
But I need it so that when frame 71 is entered the boxes are filled in
Notice in my file, when it gets to frame 71 it calls the same function again? you can do that or something like that in yours.
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.