A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: AS2 automatic update fields - help

  1. #1
    Junior Member
    Join Date
    Aug 2009
    Posts
    6

    Question AS2 automatic update fields - help

    Hi everybody

    I need a little help for making my movie-application perfect. I have made this app:

    www.uddannelsesfonde.dk/beregner

    don't spend time trying to read it because it's in danish Just so you can see how it works.

    I need it to change the final amount (last box) if I choose another one from the scroll down bar. (right now the final amount does not update when first option is changed.

    Its at simple array form which multiply with the second box and give me a anwser.

    The code:

    //This is used for the scroll down bar. It get's the info from a array.

    on(change){
    _root.message=_root.manufacturers.selectedItem.dat a;
    _root.text=_root.manufacturers.selectedItem.text;


    }
    //This is used for the second box where the calculations take place.

    on(change){ with(_parent){

    resultat.text = Number (message_txt.text) * Number

    (antal.text);

    value = Math.round ((resultat.text)) + ",00 kr.";}
    Any ideas? Need more info, then just say it thx!

  2. #2
    Flash/Flex Developer samac1068's Avatar
    Join Date
    Apr 2007
    Location
    Here, no there
    Posts
    1,813
    You should create a separate calculation function. It will take the information from the first two boxes and display the results in the third box. The onChange events for the dropdown list and the text fields should call this new function. Whenever there is a change, the make is recomputed and display in the result field. For example:
    PHP Code:
    (Dropdownon(change){
        
    _root.message=_root.manufacturers.selectedItem.data;
        
    _root.text=_root.manufacturers.selectedItem.text;
        
    recomputeResult();
    }

    (
    TextFieldon(change){ with(_parent){
        
    recomputeResult();
    }

    function 
    recomputeResult(){
       
    resultat.text Number (message_txt.text) * Number(antal.text);
       
    resultfield.text Math.round ((resultat.text)) + ",00 kr.";

    Last edited by samac1068; 08-21-2009 at 11:13 AM. Reason: Giving an Example
    Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.

  3. #3
    Junior Member
    Join Date
    Aug 2009
    Posts
    6
    Quote Originally Posted by samac1068 View Post
    You should create a separate calculation function. It will take the information from the first two boxes and display the results in the third box. The onChange events for the dropdown list and the text fields should call this new function. Whenever there is a change, the make is recomputed and display in the result field. For example:
    PHP Code:
    (Dropdownon(change){
        
    _root.message=_root.manufacturers.selectedItem.data;
        
    _root.text=_root.manufacturers.selectedItem.text;
        
    recomputeResult();
    }

    (
    TextFieldon(change){ with(_parent){
        
    recomputeResult();
    }

    function 
    recomputeResult(){
       
    resultat.text Number (message_txt.text) * Number(antal.text);
       
    resultfield.text Math.round ((resultat.text)) + ",00 kr.";

    Thx for the reply. I tried it now but can't get it to work. It will not make the intial calcualtions. Do I need more code than the recompute?

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