A Flash Developer Resource Site

Page 2 of 3 FirstFirst 123 LastLast
Results 21 to 40 of 41

Thread: Get your 25fps flash movie to actually run at 25fps in IE

  1. #21
    Senior Member
    Join Date
    Jun 2005
    Posts
    203
    yea, but the problem is that if someone does run it at 29 frames a second then there'll be a big problem.

  2. #22
    SaphuA SaphuA's Avatar
    Join Date
    Oct 2002
    Location
    The Netherlands
    Posts
    2,182
    aquaCorpse, let me clear your mind
    Normaly, when you've made a game, set it's fps to 25 in Flash, and run it iexplorer; it'll usually run at 22 fps. This is because some issues that the Flashplayer has with browsers, I won't go into too much detail there

    Anywayz, the loss of 3 fps isn't too bad, but it can still bother perfectionists who realy want a steady fps (or some games just require it).

    Now PerciPea came with the wonderfull idea, of actually having your fps to run at a steady 25 when you want it too. However, this appeared not to be working at all, because it'll still have the 3 fps drop we were trying to get rid off.

    That's the whole story, basicly

  3. #23
    Senior Member
    Join Date
    Sep 2004
    Posts
    633
    wmode = transparent will make it run in IE without any drops in frame rate.

  4. #24
    SaphuA SaphuA's Avatar
    Join Date
    Oct 2002
    Location
    The Netherlands
    Posts
    2,182
    Yeah! How does that whole wmode thing work? What is it for, what does it change, and why does it help with getting a steady fps?

  5. #25
    Senior Member
    Join Date
    Jun 2005
    Posts
    203
    whats wmode anyways?

  6. #26
    Flashoholic OneMrBean's Avatar
    Join Date
    Feb 2002
    Posts
    168
    wmode means Window Mode. Under the "publish" settings for your FLA file, go to the HTML tab and change the "Window" parameter to "Transparent". When you publish your SWF and view it in that HTML file, you'll notice that it runs pretty much as smoothly as it would when not in a web browser. I use transparent windows on my website when users view my movies, games, and experiments, because I don't want the public to view something slower than I intended. It really does help. There's a few gripes, though.

    Certain coding on the page itself (frames, javascript, etc) may interfere with the movie clip. For example, my game, Gingerbread Run, at pnflashgames.com, ran pretty slow compared to what I compiled it at. I requested that the webmaster change the wmode to be transparent. To my surprise, he did (Leason is a great guy), but he had to soon change it back because pressing spacebar in the game would cause the window to scroll down.

    However, that's a good thing, since it forced me to learn some of the ways of optimization. Yes, the sticky at the top of this forum works wonders (although it would be nice if all of the hard facts were editted into the first post, so newbies wouldn't have to read through several hundred posts to find them all).... I digress.

    In short, Wmode transparent creates the swf on top of the html file, allowing it to run independent from the browser, if I remember correctly. That's why running two html files with transparent wmode's have a bigger hit on the cpu than having two regular wmodes.

    Okay, done rambling.

    - OneMrBean
    Last edited by OneMrBean; 07-10-2005 at 01:22 PM.

  7. #27
    Senior Member
    Join Date
    Sep 2004
    Posts
    633
    Yes, you may have to adjust your onKeyPress-es in some situations. And wmode will screw with Firefox, so don't use it in embed tags. Firefox is lame when it comes to flash anyway and nothing really helps there.

  8. #28
    CRT Boy mclelun's Avatar
    Join Date
    Dec 2002
    Location
    happy land
    Posts
    299
    for the wmode, it does not really need to be in transparent to let it run in the desire fps,

    just put it in opaque or any other mode will do as well.

    but if u use wmode parameter, then ur game will not accept keyboard press event in Firefox. i had ask this question on this forum how to fix this problem, but seems that this is a bug

  9. #29
    AquaCorpse saves the day again
    Join Date
    Jun 2005
    Posts
    40
    ah i see that for clearing my mind SaphuA one might say enlightened
    aqua corpse he's a really cool guy...

  10. #30
    Senior Member webgeek's Avatar
    Join Date
    Sep 2000
    Posts
    1,356
    For reference, all the code above does is burn CPU processor time in an attempt to slow flash down. It's called a "spin loop" when you do it accidentally. Flash doesn't provide the ability to "wait" or "sleep" like other langauges so there is no way to slow it down directly. Additionally, it's very memory intensive as its creating new objects for every iteration.

    A better solution for true frame independence is to make your animation time based rather then frame based and then you can run at any framerate you want. Electrotank has started to do this for all our multiplayer games. Its a bit more work up front but it makes the game scale framerates dynamically. Additionally, it's VERY helpful for synchronizing remote computers. You can even do some tricky things like update certain aspects of the display less often to improve performance. Dynamically removing frame detail on the fly.

  11. #31
    Say hello to Bob Kakihara's Avatar
    Join Date
    Jul 2004
    Location
    kent, England
    Posts
    1,067
    Any chance of elaborating on this some more webgeek?

    Or just point me in the vicinity of some tutorials or something, ive heard about this before but I dont get how you achieve it and I havent found anything about on it.

    Ive got this diablo type game im dying to make, I have the main engine in place but I want more enemies on screen damn it, I can get it to run with 10 on screen, but im looking for more like 25.

    Thanks.
    If our body is a clock ticking away and if while we experience all that this world has to offer time has still continued to pass, are we living or just experiencing a slow death?

  12. #32
    Senior Member ihoss.com's Avatar
    Join Date
    Oct 2004
    Location
    Norway
    Posts
    581
    instead of doing
    code:

    this.onEnterFrame = function(){
    //everything you want to do
    }


    you do
    code:

    fps=25;
    function frame() {
    //everything you want to do
    }
    setInterval( frame, 1000/fps );


  13. #33
    Senior Member webgeek's Avatar
    Join Date
    Sep 2000
    Posts
    1,356
    Close, but not quite ihoss. The point isn't to try and run at a set interval (thats really all frames are), its more to make it so the code doesnt care about the interval, it just updates the position based on however long it's been. I've gone ahead and posted a new thread with some examples 'cause a few people asked me about this...
    http://www.flashkit.com/board/showthread.php?t=639640

  14. #34
    Amiga freak Ironclaw's Avatar
    Join Date
    Jan 2001
    Location
    Sweden
    Posts
    1,651
    I got 25 with limit and 93 without.

  15. #35
    Amiga freak Ironclaw's Avatar
    Join Date
    Jan 2001
    Location
    Sweden
    Posts
    1,651
    OMG! YAY!.. I have always had that problem with all my Flash game parody movies, and with my kung fu game. The speed I want the movies to run in is 100% when playing it from the standalone flash player, but always much slower in IE, so what I have ALWAYS done is having a silent streaming sound in the back. Using a streaming sound in the back makes everything run in the exact same speed in IE as in the flashplayer. However, the downside of doing this is that if someone has a slow computer, the movies/games will be very jumpy (not fun to watch/play), but I had no choise.

    Now when I'm working on my Moonstone project, I had the same problem, SO... I changed the wmode and it runs perfect in IE :P. Big thanks MikeMD.

    Game with wmode: Link
    Game without wmode: Link
    Last edited by Ironclaw; 07-12-2005 at 09:54 AM.

  16. #36
    Junior Member
    Join Date
    Mar 2008
    Posts
    8
    This is a good idea for all flash movies, It's indeed very wise to make your fps independant from the Player's FPS.. But what you are doing is called a 'busy wait', which will hog up all CPU.. Read this post (not by me), also online: :


    Quote Originally Posted by Troy Gilbert
    Troy Gilbert Says:
    May 19th, 2006 at 10:46 pm
    [...]

    The technique described is what’s commonly referred to as a “fixed timestep” in traditional gamedev. There’s a coder named “Jare” that has a good example of it (in C++) if you want to give google a shot.

    The problem with this approach is it “busy waits.” Busy waiting will effectively prevent the Flash Player from handling it’s background work (e.g., garbage collection). This will force it to do the background work once your frame completes, thus further delaying your next frame which further delays the frame after that and so on… the end result can be a vicious cycle if the loop is not limited.

    I suspect this problem is occuring because I ran into the same problem as Loma did above (with a similarly powered machine). This appears to me to be a classic unregulated fixed timestep issue. See Jare’s comments on undersampling/oversampling to prevent this.

    The ideal is to not busy wait, but rather keep the Flash Player’s “loop” going so that background tasks (garbage collection mainly) get performed at the Player’s leisure. I’ve just picked up Flash over the last week or so (using only the excellent Flash Develop, no MM Flash IDE for me!) so I don’t have this quite working yet, but here’s my plan:

    Since Flash already has a main loop (onEnterFrame event handler), I’m using it as my main game loop. Each time my event handler is called I determine the delta since the last frame (getTimer). I accumulate this each frame. Once my accumulator exceeds a given threshold (the length of time my desired frame would take, i.e. 1000/12 for 12fps if using getTimer) I run my internal game update. I then decrement my accumulator by whatever is appropriate for my desired framerate (1000/12 for 12fps).

    At this point, the accumulator may still have too much time in it (if the user’s Flash Player’s frame rate is lower than your desired fps, for example). Here you need to decide whether you run your game loop again (and decrement the accumulator) and again until the accumulator drops below the threshold (in which case your total onEnterFrame update will take longer and longer and eventually timeout the Flash Player). Or, do you skip ahead to catch up (which may or may not work depending on your game engine). I usually choose to simply max out at rendering one update per Flash Player frame. That way the game simply slows down if the user’s Flash Player slows down, but my game never causes the player to slow down progressively worse (as I and Loma saw with your example). This would be the wrong decision for network play as it would likely cause a desync between players (or force all players to slow down to the slowest player).

    I should note: the supermario game worked as expected on my laptop at home, which is actually a much slower machine than my desktop I’m using right now at work (which was afflicted like Loma described above).
    Last edited by +Noi; 04-18-2008 at 01:20 PM.

  17. #37
    SaphuA SaphuA's Avatar
    Join Date
    Oct 2002
    Location
    The Netherlands
    Posts
    2,182
    You do know you just dug up a 7 year old thread?

  18. #38
    Junior Member
    Join Date
    Mar 2008
    Posts
    8
    Quote Originally Posted by SaphuA
    You do know you just dug up a 7 year old thread?

    Google made me do it ^^.

  19. #39
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,227
    Quote Originally Posted by SaphuA
    You do know you just dug up a 7 year old thread?
    Not even 3

  20. #40
    Script kiddie VENGEANCE MX's Avatar
    Join Date
    Jun 2004
    Location
    England
    Posts
    2,590
    I presume SaphuA was judging by PercyPea's join date.
    http://www.birchlabs.co.uk/
    You know you want to.

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