dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: sleep(msecs) for super Gurus

  1. #1
    Junior Member
    Join Date
    Mar 2001
    Posts
    27
    Hi,

    Does anyone know if it is possible to have flash sleep(100). The way you would in C?

    I have done a few experiments on this and found that indeed you can sleep with the following code:

    function sleep(secs){

    secs*=1000;

    now = new Date();
    now.getTime();

    while(cur-now<secs){
    tm = new Date();
    cur = tm.getTime();
    }
    trace("SLEEP DONE");
    return 1;
    }

    However, it is ineffective, since if you..
    for(i=0;i<10;i++){
    sleep(1);
    this._x +=10;
    }
    ... flash renders the graphics all at once (_x+=100) 10 seconds later. Instead it should increment the graphics every second but the player does it all at one time.

    Now this wont work, but do any of you super Gurus ou there know how to emulate a sleep function and bypass this abnormality with flash?

    Cheers,

    Michael Collins


  2. #2
    I believe Flash needs to progress a frame in order to render your graphic everytime it runs through your for statement. You could try making your graphic 3 frames.

    Frame 1:
    i = 0;

    Frame 2:
    if (i < 10) {
    sleep(1);
    this._x +=10;
    }else {
    gotoAndStop(1);
    }

    Frame 3:
    i++;
    gotoAndPlay(2);

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