A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: [F8] A selective check button!

  1. #1
    Member
    Join Date
    May 2007
    Posts
    39

    [F8] A selective check button!

    My problem is this.
    A sum of money is attached to the screen. This sum is comprised of images of various coins . The user is to add up the coins and fill in an Input text field with that calculation.If they are right they move on to the next combination.
    Everything works except .21 (Twenty one cents). Twenty works and twenty two works .Other sums work as well.
    The check is accomplished by a "Conditional statement",triggered by an onRelease event.
    I am wondering if it is a good idea to uninstall "Flash from time to time as the only thing I can figure is that the programme has somehow become corrupt over the past number of years.
    Let me know what you think
    Thanks
    Mango

  2. #2
    Senior Member Robb@exo's Avatar
    Join Date
    Jun 2003
    Location
    Canada
    Posts
    1,540
    This may be nothing but have you tried using Math.round(); within your condition statement?
    Wile E. Coyote - "Clear as mud?"

  3. #3
    Member
    Join Date
    May 2007
    Posts
    39

    selective check btn

    myBtn.onPress = function() {
    ted = Math.floor(Math.random()*my_Array.length);
    trace(ted);
    username_txt.text = my_Array[ted];
    if (username_txt.text == .21)
    {
    trace("it's working");
    }
    else
    {
    trace("it's not");
    }
    };
    This is an example of the problem I am having.Whenever .21 is the number in the text field I get the "trace" from the "else"

    I can't figure it out .Other numbers put into the field will display a "it's working".
    Thanks
    Mango

  4. #4
    Senior Member vinayak.kadam's Avatar
    Join Date
    Oct 2006
    Location
    gotoAndPlay("Pune");
    Posts
    831
    Very strange! Can u please upload your FLA....so that we can have a look at it?
    As ever,
    Vinayak Kadam

  5. #5
    Senior Member Robb@exo's Avatar
    Join Date
    Jun 2003
    Location
    Canada
    Posts
    1,540
    Hmmm... interesting
    Last edited by Robb@exo; 11-03-2008 at 02:49 AM.
    Wile E. Coyote - "Clear as mud?"

  6. #6
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    well Im not sure what it is your doing..... is most of the code..

    but if you check a text field for its data.. its treated as a string...

    hence you need to check for a string.. (ie: ".21")...

    Im not sure why the other stuff is working... and this is not..

    if the array is a number that you pass in...then the text field will show

    myArray = [.21, .33];
    username_txt.text = myArray[0];
    trace(username_txt.text);

    // traces 0.21

    which is what you'd need to check for...

    if (username_txt.text == "0.21") {
    trace("it's working");
    } else {
    trace("it's not");
    }

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