A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: As2 Question Button that counts read to understand

  1. #1
    Member
    Join Date
    Sep 2010
    Posts
    73

    As2 Question Button that counts read to understand

    Ok I want to make a button that changes a text to count 21+

    so lets say we have our button

    Code:
    button.onRelease = function()
    {
    
    
    }
    Ok lets say we have a dynamic text

    Code:
    button.onRelease = function()
    {
    
    ourtext.text ="0";
    
    }
    Ok every time I click the button I want the ourtext.text ="0";
    to count + 21

    so if i click it once is the ourtext.text ="21";
    if I click it again its ourtext.text ="42";

    and soon untill limit of 5000

    How can I do that?
    WiiStream A Social Movie Network Version 0.1.1 Demo Testers Aproved http://wiistream.net/WiiStream.exe

  2. #2
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Assigning a number directly to a textfield, with or without quotes, will result in that turning into a string, which will not matemathically add 21 to the number, but after it, because it will recognize it as a string. What you can do, is to make a variable, and increase it, and then assign that value to your text field:

    Actionscript Code:
    number_value = 0;
    ourtext.text = number_value;

    button.onRelease = function()
    {

        if(number_value < 5000)
        {
            number_value += 21;
            ourtext.text = number_value;
           
        }

    }

    Hope it helps
    Last edited by Nig 13; 10-24-2011 at 02:27 PM.
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

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