dcsimg
A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: How to count up to a given integer

  1. #1
    Junior Member
    Join Date
    Mar 2002
    Posts
    17
    Hi folks,

    im not that experienced in AS

    well, i just want to code a simple counter that counts from 0 to a given integer.

    for example and my thoughts:

    a given textfield for the countoutput named "showme" with presetted integer 0

    code for it

    showme=Number(showme)+1

    runs in a loop on the timeline

    well, problem now, this line of code, counts infinite, and i just want to count to a given integer.

    What to code that this counter stops at, for example, at 200

    Maybe an "IF" command would help, dunno exactly.

    thx in advance

  2. #2
    Senior Member
    Join Date
    Mar 2002
    Posts
    334
    Code:
    for(i; i<=100; i++)
    { 
      trace(i);
    }
    Just replace 100 with what ever number you want and replace trace with something like

    myTextBox.text = i;


  3. #3
    Senior Member
    Join Date
    Jul 2000
    Posts
    126
    Originally posted by Squareball2
    Code:
    for(i; i<=100; i++)
    { 
      trace(i);
    }
    Just replace 100 with what ever number you want and replace trace with something like

    myTextBox.text = i;

    This will count to 100 in a single frame - probably not what was intended.

  4. #4
    Senior Member
    Join Date
    Mar 2002
    Posts
    334
    Originally posted by nmain
    Originally posted by Squareball2
    Code:
    for(i; i<=100; i++)
    { 
      trace(i);
    }
    Just replace 100 with what ever number you want and replace trace with something like

    myTextBox.text = i;

    This will count to 100 in a single frame - probably not what was intended.
    From what the original poster said, that is what I gather they want to do. What do you think they mean?

  5. #5
    Senior Member
    Join Date
    Mar 2002
    Posts
    334
    oh wait do you mean like it should show 1 then 2 then 3 and so on?

  6. #6
    Junior Member
    Join Date
    Mar 2002
    Posts
    17

    Yea helps a bit

    well, last post is right.

    the original idea for what i want to use that counting stuff is a scripted animation.

    i just need a textbox and a piece of script that counts from 0 to the "xmouse" integer returned by getproperty, to move one endpoint from a line from XY pixel 0 to XY pixel of returned value of xmouse property.

    thats all, but dunno how to count up to an integer that is already defined.

    the for loop works, but it counts that fast that the line reaches immediatly the return XY value my xmouse property at movie startup.


  7. #7
    Senior Member
    Join Date
    Mar 2002
    Posts
    334
    Ok try this ON a movie clip

    Code:
    onClipEvent(enterFrame)
    {
      i;
      if(i <= 100) 
      {
        i++
       }
      _root.theTextBox.text = i;
    
    }
    Make sure that you target your text box correctly.
    That should work.

  8. #8
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    textfield on stage _root.showme

    Create an empty movie clip, drag it on stage and add this script to it with onClipEvent(enterFrame):

    onClipEvent (enterFrame) {
    if (count>200) {
    _root.counter.stop();
    } else {
    _root.showme = count++;
    }
    }

    Forgot to mention that the instance name of the mc is counter!
    [Edited by oldnewbie on 04-14-2002 at 09:02 PM]

  9. #9

  10. #10
    Junior Member
    Join Date
    Mar 2002
    Posts
    17

    it works :)) but runs really crappy

    http://www.elektrobong.com/linemove.fla

    current version of the linepointmovement im trying to figure out.

    works really ****, but better than before with no function and a brain shortly before blow up.

    help to this would be nice, because i have no idea how to code a smooth working linepointmovement.

    thx a lot in advance, still trying to figure that out

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