flash "for"

  • [PT]volumes
  • Novice
  • Novice
  • [PT]volumes
  • Posts: 28

Post 3+ Months Ago

hi all,

first of all, im a little noob at flash, so i would just like to know a simple thing... like when i load the project i put a for running between 0 and 100 and show the result on a dynamic text field, but i only see the number "100" cuz its to fast... there is anyway to put this showing each number in a second ?

CODE:

Code: [ Select ]
for(z=0; z<=100; ++z){
  this.buh = z;
}
  1. for(z=0; z<=100; ++z){
  2.   this.buh = z;
  3. }


Regards.
  • Reinholdt
  • Newbie
  • Newbie
  • Reinholdt
  • Posts: 5
  • Loc: Denmark

Post 3+ Months Ago

Hi There

Here Is one way to do it :-)

Code: [ Select ]
var interval = setInterval(count, 30);
var counter = 0;

function count() {
    _root.txtField.text = counter;
    if (counter == 100) {
        clearInterval(interval)
    }
    counter++;
}
  1. var interval = setInterval(count, 30);
  2. var counter = 0;
  3. function count() {
  4.     _root.txtField.text = counter;
  5.     if (counter == 100) {
  6.         clearInterval(interval)
  7.     }
  8.     counter++;
  9. }


Best Regards

Reinholdt
  • [PT]volumes
  • Novice
  • Novice
  • [PT]volumes
  • Posts: 28

Post 3+ Months Ago

Reinholdt wrote:
Hi There

Here Is one way to do it :-)

Code: [ Select ]
var interval = setInterval(count, 30);
var counter = 0;

function count() {
    _root.txtField.text = counter;
    if (counter == 100) {
        clearInterval(interval)
    }
    counter++;
}
  1. var interval = setInterval(count, 30);
  2. var counter = 0;
  3. function count() {
  4.     _root.txtField.text = counter;
  5.     if (counter == 100) {
  6.         clearInterval(interval)
  7.     }
  8.     counter++;
  9. }


firts, thks for ur help.

Now, i cant understand all, like, i put that in my *fla, but now the number stays on value "0". just put that code or mine to ? :s

if can can of course, can u give me an example ? or make one please... :\ sorry.

regards.

Best Regards

Reinholdt
  • classified
  • Expert
  • Expert
  • User avatar
  • Posts: 540
  • Loc: Bahrain

Post 3+ Months Ago

no u dont need to use your code ..
its this way , i will try commenting .. copy and paste the following in your actions
and make sure you got a dynamic text field on the stage with the instance name of textField .


Code: [ Select ]
//usining setInterval function you can call a function every x time
//as u can c in this example he is calling count every 30 ms .
var interval = setInterval(count, 30);
// counter , the variable that will be holding numbers ...
var counter = 0;

function count() {
  _root.txtField.text = counter;

  //if counter = 100 then kill the interval , you dont want to go above 100 ..
  // Using clearInterval(functionName);
  if (counter == 100) {
   clearInterval(interval)
  }
  //not yet reached 100 so increase it ++
  counter++;
}
  1. //usining setInterval function you can call a function every x time
  2. //as u can c in this example he is calling count every 30 ms .
  3. var interval = setInterval(count, 30);
  4. // counter , the variable that will be holding numbers ...
  5. var counter = 0;
  6. function count() {
  7.   _root.txtField.text = counter;
  8.   //if counter = 100 then kill the interval , you dont want to go above 100 ..
  9.   // Using clearInterval(functionName);
  10.   if (counter == 100) {
  11.    clearInterval(interval)
  12.   }
  13.   //not yet reached 100 so increase it ++
  14.   counter++;
  15. }

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 5 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.