A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: Help an old fogie

  1. #1
    Ancient Member
    Join Date
    Nov 2000
    Location
    Somewhere
    Posts
    139

    Help an old fogie

    Unfortunately it's been a couple years since I touched flash, and while I've sort of kept up with things, I'm having trouble doing something the "Right" way.

    I'm updating an old flash program of mine which timed a users reaction. The old way I did it was to crank up the framerate to 120 frames/second (the highest flash 5 could go) displaying the start graphic as close as possible to when I wanted (I really wanted 1/250 of a second accuracy) and on each onClipEvent(enterframe) check to see if the button had been pressed.

    I remember reading somewhere a year or so ago about a newer actionscript command which would redraw the stage even in between frames, and thinking that would let me set the flash movie to a "sane" framerate and still keep the accuracy I was looking for. However I can't remember the name of the command, and searching everything I can think of has turned up nothing. What is the correct (or at least MX2004 and above) method of doing this?
    It's nice to be important, but it's more important to be nice." - Hans-Peter Geerdes

  2. #2
    Can't Re-Member madzigian's Avatar
    Join Date
    Apr 2004
    Location
    Boston MA
    Posts
    2,662
    not sure exactly what you're looking for wothout seeing your FLA...(i don't know what's going on in the movie.. what kind of animation it is... what interaction is happening, etc) you should look into setInterval()

    there is also a MovieClip.prototype that will tune your fps up or down:
    Code:
    /****************************************
    DESCRIPTION
    
     Use this to tuneUp your fps of your movieclip.
     you can alter the main timeline of the mc and if required alter the fps of the 
     nested mc's
    ****************************************/
    //
    /*************************************
    CODE
    *************************************/
    //
    MovieClip.prototype.tuneUp = function(fps, inherit, dir, endF) { 
     * *var intv, mc, d, end; 
     * *intv = 1000/fps; 
     * *d = (dir == "down") ? -1 : 1; 
     * *if (!endF) end = (dir == "down") ? 1 : this._totalframes;* * 
     * *clearInterval(this.tuneUpID); 
     * *this.tuneUpID = setInterval(fineTune, intv, this, d, this._currentframe, end); 
     * *if (inherit) { 
     * ** *for (var i in this) { 
     * ** ** *if (typeof (this[i]) == "movieclip") { 
     * ** ** ** *clearInterval(this[i].tuneUpID); 
     * ** ** ** *this[i].tuneUpID = setInterval(fineTune, intv, this[i], d, this[i]._currentframe, end); 
     * ** ** *} 
     * ** *} 
     * *} 
     * *function fineTune(mc, d, sf, end) { 
     * ** *_if = (sf<end) ? mc._currentframe < end : mc._currentframe > end 
     * ** *if (_if) { 
     * ** ** *mc.gotoAndStop(mc._currentframe+d); 
     * ** *} else { 
     * ** ** *clearInterval(mc.tuneUpID); 
     * ** *} 
     * *} 
     }; 
    
    
    
    /*************************************
    USAGE
    *************************************/
    //
    // alter all the mc's on the stages timeline by
    _root.tuneUp(100, true);
    //
    // sets _root.yourMC fps to 100 playing forward without altering of the child mcs, that will stop on the last frame 
    _root.yourMC.tuneUp(100);
    //
    // sets _root.yourMC fps to 20 playing forward, including the child mcs 
    _root.yourMC.tuneUp(20, true);
    //  
    // sets _root.yourMC fps to 50 playing backward if the currentframe is greater than 20, without altering the child mcs 
    _root.yourMC.tuneUp(50, false, "down", 20);
    if you can post your FLA... it'll be easier to figure out what's going on and update it for you
    Please DO NOT PM me simply for individual help. Post in the public forums...that's what they are for, and they allow others to benefit as well. - Thx
    OS X 10.3.9 || Flash MX04 Pro
    | del.icio.us || furl || Helpful Source Files || Free Pixel Fonts |

  3. #3
    Ancient Member
    Join Date
    Nov 2000
    Location
    Somewhere
    Posts
    139
    Attached is a version of the fla I'm working on with the old code. It's a drag racing practice tree. Press the up arrow to pre-stage, press again to stage, and press again to go. Press the down arrow to reset to try again.

    I just know there has to be a smarter way of making sure the lights turn on every .500 of a second rather than checking if I need to turn it on 120 times a second, but I just can't remember how to do it, and to re-draw the stage at exactly the right moment.

    Thanks for your help.
    Last edited by Skraut; 03-02-2006 at 04:09 PM.
    It's nice to be important, but it's more important to be nice." - Hans-Peter Geerdes

  4. #4
    Can't Re-Member madzigian's Avatar
    Join Date
    Apr 2004
    Location
    Boston MA
    Posts
    2,662
    i can''t open your file... it must be a Flash 8 file huh?... save it down to MX04
    Please DO NOT PM me simply for individual help. Post in the public forums...that's what they are for, and they allow others to benefit as well. - Thx
    OS X 10.3.9 || Flash MX04 Pro
    | del.icio.us || furl || Helpful Source Files || Free Pixel Fonts |

  5. #5
    Ancient Member
    Join Date
    Nov 2000
    Location
    Somewhere
    Posts
    139
    Sorry I saved it as 8 to get it under the 300k limit.

    www.norwalkraceway.com/designs/Tree-Right.zip
    It's nice to be important, but it's more important to be nice." - Hans-Peter Geerdes

  6. #6
    Can't Re-Member madzigian's Avatar
    Join Date
    Apr 2004
    Location
    Boston MA
    Posts
    2,662
    ok... what exactly is supposed to be happening here?... i got the arrow up to change the lights... do you want that to be automatic?... please give me a l;ittle more detail
    Please DO NOT PM me simply for individual help. Post in the public forums...that's what they are for, and they allow others to benefit as well. - Thx
    OS X 10.3.9 || Flash MX04 Pro
    | del.icio.us || furl || Helpful Source Files || Free Pixel Fonts |

  7. #7
    Ancient Member
    Join Date
    Nov 2000
    Location
    Somewhere
    Posts
    139
    This is a simulation of a starting tree for Drag Racing. Hit the up arrow once and the top lights turn on, hit it again and the second lights come on. Turning on the second set of lights tells the timing system you are ready. Then between .5 and 1.5 seconds later, the yellow lights turn on and each one turns on .5 seconds after the previous one. You want to hit the up arrow once again just as the green light turns on and try to get as close to zero as possible without going under.

    Right now the computer counts down to turn on the lights by using onClipEvent(enterframe) not setInterval (which is what I couldn't remember) and I want to streamline the code a bit by using setInterval.
    It's nice to be important, but it's more important to be nice." - Hans-Peter Geerdes

  8. #8
    Can't Re-Member madzigian's Avatar
    Join Date
    Apr 2004
    Location
    Boston MA
    Posts
    2,662
    ok... i gotta be honest ... the how's why's and what's of setInterval still elude me... I'd suggest doing a few searches here in the forums (as i know there are a ton of setInterval() threads. Also, here are a few links that might help get you going...
    http://www.kirupa.com/developer/acti...etinterval.htm
    http://www.actionscripts.org/tutoria...al/index.shtml

    sorry... but setInterval is really not my thing... i can write some basic generic pasuse functions, but that's about it. The Kirupa tutorial should help you with a countdown..
    Please DO NOT PM me simply for individual help. Post in the public forums...that's what they are for, and they allow others to benefit as well. - Thx
    OS X 10.3.9 || Flash MX04 Pro
    | del.icio.us || furl || Helpful Source Files || Free Pixel Fonts |

  9. #9
    Ancient Member
    Join Date
    Nov 2000
    Location
    Somewhere
    Posts
    139
    Thanks a bunch for your help anyway. I spent quite a while searching, and couldn't figure out to search for setInterval. At least I'm on the right track now.
    It's nice to be important, but it's more important to be nice." - Hans-Peter Geerdes

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