dcsimg
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: getTimer() function

  1. #1
    Member
    Join Date
    Jun 2000
    Posts
    50
    I need an action to occur only if the user has not completed a specific action. Basically this should occur 5 seconds from a given keyframe. I created a blank movie clip at that keyframe and gave it the following actions:

    if (getTimer() > 5000) {
    _root.clipboard.nextFrame();
    }

    The script says it has errors - what am I doing wrong?

  2. #2
    Senior Member
    Join Date
    Apr 2002
    Posts
    682
    getTimer() will reach 5000 five seconds after your flash starts, so you may have more than one problem. First you need to define a 5 second window, for example:

    on(press) {

    nowTime=getTimer();
    }

    // Then some place else

    if (nowTime==nowTime+5000) { do whatever }


  3. #3
    Member
    Join Date
    Jun 2000
    Posts
    50
    Right, that makes sense. I also needed an onClipEvent. All I really needed to do was adjust my timer to account for the part of the movie that has already been played and add a variable - here's what I have:

    onClipEvent (load) {
    while(true) {
    if (getTimer() > 27500 && !(_global.clipUp)) {
    _root.clipboard.nextFrame();
    _global.clipUp = true;
    }
    }
    }

    This really doesn't work, but I don't know how else to get the condition to be continually checked.

  4. #4
    Senior Member
    Join Date
    Apr 2002
    Posts
    682
    You may still have problems with that. What if the file starts and the user sits there without doing anything for 10 minutes?

  5. #5
    Member
    Join Date
    Jun 2000
    Posts
    50
    Here is what I ended up with (it works):

    onClipEvent (enterFrame) {
    if (getTimer() > 27500 && !(_global.clipUp)) {
    _root.clipboard.nextFrame();
    _global.clipUp = true;
    }

    }

    It's ok if the user doesn't do anything from the beginning, because the action does not occur until a stop anyway. The only way the user can 'change' the timeline would be to hit the spacebar and bring up a menu, which then sets clipUp to true and I don't worry about doing it for them. Thanks for your help.

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