A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Help with Actionscript text input

Hybrid View

  1. #1
    Member
    Join Date
    Sep 2000
    Posts
    43
    I want to create a math problem that the user inputs the data to be computed.

    example:

    220 - textinput = answer

    I just started with scripting. I know Lingo fairly well and now trying to learn actionscripting.

    Thanks

  2. #2
    Senior Member
    Join Date
    Nov 2000
    Posts
    168
    I think you would go about it like this.

    Have an input text box named "textInput" . Then you can store the answer in a variable:

    var answer = 220 - _root.textInput
    //_root is wherever you have placed your text box, in this case its the main timeline.

    dan

  3. #3
    curmudgeon swampy's Avatar
    Join Date
    Jan 2001
    Location
    [wakey]
    Posts
    2,775
    name the input text box "textinput" in the "text options" pallette. draw a dynamic text box and name it "answer"
    and add this script to a button:
    Code:
    on (release) {
    
    answer= 220 -textinput;
    
    }

  4. #4
    Member
    Join Date
    Sep 2000
    Posts
    43
    Thanks

    I'm working with now.

    Is it possible not to have a button to generate the answer, rather as the user types in the "textinput" field. I want the answer to display automatically.

  5. #5
    curmudgeon swampy's Avatar
    Join Date
    Jan 2001
    Location
    [wakey]
    Posts
    2,775
    yes, if you make the movie two frames long and add this code in the first frame of the main timeline

    answer= 220 -textinput

    the movie will constantly loop through the script as it loops through the frames

  6. #6
    Member
    Join Date
    Sep 2000
    Posts
    43
    Ok, not sure whats happening.


    Ok, here's what I got so far.

    frame 1:
    the user see's on screen

    220 - "textinput" = answer

    textinput & answer are invisible until something is typed in the "textinput" field.

    However, when i used the code:
    220 - textinput = answer; "220" is displayed where the answer should be. The real answer should be "185"

    Sorry for my inability to understand this. In Director, I declare my varibles first, as in:

    set varible textinput, answer

    then write out the expression

    220 - textinput = answer

    Are their any simalarities with Lingo and Actionscripting?

  7. #7
    curmudgeon swampy's Avatar
    Join Date
    Jan 2001
    Location
    [wakey]
    Posts
    2,775
    get shot of the quotation marks around the variable name otherwise flash interprets it as a string literal.

    write your code in this order:

    answer= 220 -textinput
    because the answer equals 220 minus whatever textinput is

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