-
Combo box question
helloz!
i have a combo box named test (from the MX's library for UI Components) with 3 data (20, 30, 40) with their 3 labels (One, Two, Three) and i have next to it a dynamic text field named price..
i want the data of the current label that is chosen from the combo box to be displayed in the text field... (e.g. if i chose the option labeled "Two" then the text field should show the value "30")
by placing this: _root.price = _root.test.data
it gives me all the data of the combo box in the text field....
how do i do this..?
if there is another way instead of a dynamic text field you are more than welcome to share it with me..
thank you for your time guys...
-
try adding .label
I usually do something with the changeHandler like
function myCombo() {
trace(combo1.getSelectedItem().label);
}
where myCombo is the changeHandler and combo1 is the instance of the list/combo box. The above is on a frame action.
-
but i don't want to show the label.... i want to show the data which is assigned to that label...
can i used the getSelectedItem in way to link the label with the data?
or with another way?
-
oops. Sorry. Try getValue()
function myCombo() {
dynamicText_txt.text=combo1.getValue()
}
-
ok... questions....
1: this changeHandler... is it a component or this is how your method is called? if it's a component which one is it cause i cannot find it... is it supposed to manipulate "live" data? (i mean when i click the labels of the combo box)
2: my dynamic text field has Var "text1". my combo has Instance Name "Combo1". should i write this in the frame actions?:
function myCombo() {
text1.text=combo1.getValue()
}
thank you
-
1. If you click on your component and look at the properties pallet you will see where the changeHandler is. Same location where you can add data and labels. Everytime there is a change in the component, the function will run.
2. I always use frame actions. Just a personal preference. You don't need to have the variable in your text field. Just use the instance name of the text field.
In my example
function myCombo() {
dynamicText_txt.text=combo1.getValue()
}
dynamicText_txt is the instance name of the dynamic text box.
Then if you want, you can use the instance name like a variable.
function myCombo() {
dynamicText_txt.text = combo1.getValue();
myTotal_txt.text = dynamicText_txt.text*10;
}
in the above instance, if the value of what I chose was 2, then dynamicTex would be 2 and myTotal_txt would be 20.
-
thank you so much !
i am most grateful
-
-
damn it...
sorry to bother you again man...
i'm using mx 2004 pro... and in the combo box component i don't see this changeHandler in the properties...
i see only data, labels, editable and rowCount as properties....
i searched through the help file and i think i have to use the changeHandler as actionscript
any ideas/help?
-
i installed Flash MX and here i can see the changeHandler parameter...
but it doesn't work.... i tried with .data instead of .getValue() but still nothing...
i added the value myCombo() in the changeHandler... should i add something more?
i am so lost...
-
are you using the parenthesis in the changeHandler? If so, don't. Also, are you using the property panel or the ActionScript Dictionary? Use the properties panel.
Basically all the changeHandler does is call a function when the component changes.
So you have this function like this on the frame action
function myCombo() {
dynamicText_txt.text=combo1.getValue()
}
your changeHandler is myCombo.
combo1 is the instance name of the component.
Let me know how that works.
-
in MX 2004 Pro there is a Component's Inspector Panel where the parameters of the component are. and there is no changeHandler parameter. (at least i couldn't find it anywhere)
but i'm ok now... i installed mx 6.0 and i found everything there so now my combo box works just fine
thank you very much for your help and sorry to bother you so much. i promise this is my last post for this problem
-
free-webmaster-resource.com
i didnt read the whole post, but i think you meant something like this
Code:
myListener = {};
myListener.change = function(){
trace("you changed me");
}
myCombo.addEventListener("change",myListener)
-
Sorry, I did not know you were on MX2004. There is a difference. You can still use MX2004 and from the Macromedia Exchange you can download the Flash UI components that were for MX. If you will be publishing as Flash 7 then you will probably want to use the 2004 components which use listeners and not changeHandlers.
You can visit www.ultrashock.com and look at the tutorials for MX2004. They are excellent. Should be a link in the middle of the home page.
-
free-webmaster-resource.com
-
thank you guys!
i will make my movie in mx and export it in flash player 6.
my original movie is in flash player 7 from mx 2004...
but i can load the 6 inside 7 with loadMovieNum on level 1... can't i?
have you tried something similar?
-
Why are you loading 6 into 7? You can publish anyway you want.
-
i have some elements in my main movie that need to be exported as v.7 (components..)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|