A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [RESOLVED] updating dynamic text

  1. #1
    Member
    Join Date
    Apr 2007
    Posts
    56

    resolved [RESOLVED] updating dynamic text

    In this simple app I have two MC buttons each when clicked adds a value to a "total" variable which is displayed in real time. This all works fine however as you can see the button can be de-selected so I want to be able to subtract the value that was added when selected.

    This is part of a much larger form and I want the user to be able to change their mind and see the results.
    Attached Files Attached Files

  2. #2
    Senior Wabbit
    Join Date
    Jul 2008
    Location
    Winchester, Uk
    Posts
    215
    Something more like this but this is buggy with your buttons sometimes, not entirely sure, not really looked much at the file.

    Actionscript Code:
    stop();

    stotal=0;
    a1a=false;
    a1b=false;

    q1a.onRelease = function(){
        if (a1a==true){
            a1a=false;
            stotal -=75;
        }else{
            a1a=true;
            stotal += 75;
        }
    }

    q1b.onRelease = function(){
        if (a1b==true){
            a1b=false;
            stotal -=50;
        }else{
            a1b=true;
            stotal += 50;
        }
    }

    also I changed your txtfield var to stotal.

    Trust my code, and not my english.

  3. #3
    Member
    Join Date
    Apr 2007
    Posts
    56
    Dude that is perfect. I was having a heck of a time with the if then else statement. This works great. Now Ill try to impliment in the much larger file and see how it goes.

    Thanks again

  4. #4
    Member
    Join Date
    Apr 2007
    Posts
    56
    One small issue. I cleaned up the code on the buttons but having an issue with stotal value.

    If you compile and run this FLA, select the first then the second then the third choices then deselect in reverse till all are deselected you will see it returns an invalid number , should be zero (0), it also displays 4 decimal places, I have tried to add a function to limit to 2 decimal places but I can't seem to get it to work and even though I need that function not sure if it will fix the bad end value.
    Attached Files Attached Files

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