A Flash Developer Resource Site

Results 1 to 18 of 18

Thread: Combo box question

  1. #1
    Member
    Join Date
    Feb 2003
    Posts
    34

    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...

  2. #2
    Senior Member
    Join Date
    Apr 2001
    Posts
    528
    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.

  3. #3
    Member
    Join Date
    Feb 2003
    Posts
    34
    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?

  4. #4
    Senior Member
    Join Date
    Apr 2001
    Posts
    528
    oops. Sorry. Try getValue()

    function myCombo() {
    dynamicText_txt.text=combo1.getValue()
    }

  5. #5
    Member
    Join Date
    Feb 2003
    Posts
    34
    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

  6. #6
    Senior Member
    Join Date
    Apr 2001
    Posts
    528
    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.

  7. #7
    Member
    Join Date
    Feb 2003
    Posts
    34
    thank you so much !

    i am most grateful

  8. #8
    Senior Member
    Join Date
    Apr 2001
    Posts
    528
    No problem.

  9. #9
    Member
    Join Date
    Feb 2003
    Posts
    34
    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?

  10. #10
    Member
    Join Date
    Feb 2003
    Posts
    34
    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...

  11. #11
    Senior Member
    Join Date
    Apr 2001
    Posts
    528
    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.

  12. #12
    Member
    Join Date
    Feb 2003
    Posts
    34
    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

  13. #13
    free-webmaster-resource.com deamothul's Avatar
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    1,475
    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)

  14. #14
    Senior Member
    Join Date
    Apr 2001
    Posts
    528
    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.

  15. #15
    free-webmaster-resource.com deamothul's Avatar
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    1,475

  16. #16
    Member
    Join Date
    Feb 2003
    Posts
    34
    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?

  17. #17
    Senior Member
    Join Date
    Apr 2001
    Posts
    528
    Why are you loading 6 into 7? You can publish anyway you want.

  18. #18
    Member
    Join Date
    Feb 2003
    Posts
    34
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center