A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Simple, simple... input field question

  1. #1
    Senior Member vucjak's Avatar
    Join Date
    Mar 2002
    Location
    BanjaLuka, RS, Bosnia
    Posts
    306

    Simple, simple... input field question

    OK, I have two input text fields, one is var x1 and another is var x2

    onRelease I`m trying to use this code
    score = Math.sqrt (x1+1) - Math.sqrt (x2)

    It`s not working, check out attached fla file

    Thanks folks
    Attached Files Attached Files

  2. #2
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,876
    instead of using var, give your textfields instance names x1 and x2... then use

    score = Math.sqrt(Number(x1.text)+1) - Math.sqrt(Number(x2.text));

    Note: anything retrieved from a textfield is considered to be a string..so before applying any mathematics to their contents, you need to convert their contents to a number, using the Number function...

    hope that helps
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

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