Welcome, Guest
  • Author Topic: values in combobox!  (Read 1359 times)

    anil

    • Server what's that
    • *
    • Posts: 19
      • View Profile
      • Email
    values in combobox!
    « on: 08/09/04, 03:10 »
    hello everyone!
    again me;

    i wanna create number convertor but my project is a little bit difficult.
    i can not solve and i need big help.
    my flash version is Flash MX.

    my project will be like below...
    ---------------------------------------
    "input text"

    "combobox1" "combobox2"
    value1               value1
    value2               value2
    value3               value3


    "button"

    "dynamic text"
    ------------------------------------------

    Jorge Solis helped me for two value in combobox but i can not write script to third value and more...

    Below script is perfect for two value but it's diffucult to write script for new value(example value three=yourMoney).


    convert.onPress = function(){
     if(A.getSelectedItem().label==B.getSelectedItem().label){
         dollar.text = "Select different money"
         return
     }
     qty = Number(dollar.text)  
     if(dollar.text=="" || isNaN(qty)) {
         dollar.text = "Enter a sum"
         return
     }
     myMoney.text = (A.getSelectedItem().label=="dollar")?qty*1.5 : qty/1.5
    }


    thanks to read this long letter....

    Ronald Wernecke

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 6203
      • View Profile
      • Professional Support
      • Email
    Re:values in combobox!
    « Reply #1 on: 08/09/04, 05:25 »
    Hi,
    you only need one combobox having the currencies.

    Then you need an array, or db query to find a matching value, and the factor for it.

    If youre base currency is €, and your target currency is $, then you only need the number to be multiplied from $ to €.

    You can read these once from a file, and then access them from an array.
    I would write a XML file, for the ease of reading, and changing it.

    Youre XML could be looking like this:
    [code]
    <exchangerates date="20040809">
    <currency label="USD" symbol="$" factor="0,95" />
    <currency label="EUR" symbol="€" factor="1" />
    <currency lable="YEN" symbol="Y" factor="unknown" />
    </exchangerates>
    [code]
    then you can read all labels into the combo, and if the usere selected one, you can directly read the factor an present the symbol ;)
    happy flashing
    8)
    Ronald

    anil

    • Server what's that
    • *
    • Posts: 19
      • View Profile
      • Email
    Re:values in combobox!
    « Reply #2 on: 08/10/04, 00:43 »
    thanks Ronald;

    yes i will try this method but first of all i think that 2 combobox and inside many values.

    anil...  




    Ronald Wernecke

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 6203
      • View Profile
      • Professional Support
      • Email
    Re:values in combobox!
    « Reply #3 on: 08/10/04, 03:09 »
    Hi Anil,
    I dont see the need for two comboboxes ;)

    What do you select in the second one?

    Comboboxes are userinterfaces for to select values out of a list.
    If you just need an internal list, you make an array.
    happy flashing
    8)
    Ronald

    anil

    • Server what's that
    • *
    • Posts: 19
      • View Profile
      • Email
    Re:values in combobox!
    « Reply #4 on: 08/12/04, 11:24 »
    Ronald;

    my project will be like below...
    i don't need any connection.
    i think to create website about number convertor (like weights ton/kg/lb etc..). It will be similar with currency convertor in this site but i need no connection like nusoap because all data in script will be stable.
    i think that 2 combobox and inside same labels.
    Jorge Solis helped me for two labels but it's difficult to write script 3 and more...


    ---------------------------------------
    "input text"

    "combobox1"  "combobox2"
    value1               value1
    value2               value2
    value3               value3


    "button"

    "dynamic text"
    ------------------------------------------

    Below script is perfect for two value but it's diffucult to write script for new value(example value three=yourMoney).


    convert.onPress = function(){
     if(A.getSelectedItem().label==B.getSelectedItem().label){
         dollar.text = "Select different money"
         return
     }
     qty = Number(dollar.text)  
     if(dollar.text=="" || isNaN(qty)) {
         dollar.text = "Enter a sum"
         return
     }
     myMoney.text = (A.getSelectedItem().label=="dollar")?qty*1.5 : qty/1.5
    }





    Ronald Wernecke

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 6203
      • View Profile
      • Professional Support
      • Email
    Re:values in combobox!
    « Reply #5 on: 08/12/04, 11:53 »
    OK, in this case two combos make sense.

    But you have to create some logic, that you cannot calculate pound into cm or celsius into pascal ;)

    So you would need to load the second combo, after you made a selection in the first one.

    The fist combo has all the labels for the calculation base and data for the corresponding file to be loaded into the second combo ;)

    So, if you have selected meter in the first one, you get a base number of 1, and a file (like lenghts.xml) containing mm, cm, dm, m, km, yards, miles, feet .... with the corresponding factor in the data field.
    happy flashing
    8)
    Ronald