A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Textfields making flash lag weird

  1. #1

    Textfields making flash lag weird

    Man, I finally found the reason why my newest flash game has been lagging! I don't know exactly why, but I'm extremely happy I fixed it and figured it out.


    I just though this was weird, maybe someone here can lend me a hand as to why exactly this causes lag. Here's the case.


    I have a flash game that is tile based. There's about 400 tiles on the screen being shown at once. Each of these tiles had a text box in it that was used for certain purposes early on in testing. After testing, the textbox was left there (on the tiles) but had no text in it, was NOT selectable, and so could not even be seen or anything.


    The problem I was having however was that in this game, you click to shoot. If the player was to rapidly click, the mouse cursor would lag as would the game slightly. I could also notice a bit of lag during more code intense parts of the game. A BIG part of the lag came when the user was to move the mouse around the screen/flash area. I have a script timer displaying showing me the time of execution between frames, and it DEFINATELY goes up when I move the mouse around with the textfields present.

    After deleting the text boxes out of the tiles, I noticed my game is now running as smooth as ever! I've removed, then re-added the text boxes, and have come to the conclusion that they are without a doubt adding some extra bog-down to my game.

    I'm not entirely sure why having a bunch of empty text fields on the screen can further the lag, but I'm sure it's them. Does anyone know why? Maybe text field have some sort of listeners on them whenever the user clicks or mouses over I assume? But the game even lags slightly more during large animations when the text boxes are there.

    Hmm.. Yea, so overall, having a bunch of un-used textboxes on screen worsened the games performance by I'd say 40%. I realize it's not good to have a whole bunch of un-used stuff on stage, but still!

  2. #2
    Hype over content... Squize's Avatar
    Join Date
    Apr 2001
    Location
    Lost forever in a happy crowd...
    Posts
    5,926
    Yeah text boxes have a large cost to them.

    I know you were only using them for debugging, but using bitmaps for things like the score can help a lot and is fairly easy to do.
    Also you can update your eternal score var, then every second or so test to see if the dynamic text needs updating and if so do it all in one hit.

    Squize.

  3. #3
    Junior Member
    Join Date
    Mar 2009
    Location
    Dublin, Ireland
    Posts
    24
    At a guess every text box was triggering mouseOver events? (even if they didn't do anything they were still to be notified about them?).

    And yeah, switching to copyPixels() for text stuff makes it much faster. Here's a great example: http://kaioa.com/node/85

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