Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8050983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:12:25+00:00 2026-06-05T07:12:25+00:00

I’m working on a small game in Flash (AS3) that generates levels using small

  • 0

I’m working on a small game in Flash (AS3) that generates levels using small tiles.

The location,width,height and other properties of the tile are stored in an array upon generation. Each tile is added to the same container movieclip. When all tiles have been generated, the container movieclip is converted to a bitmap, all tiles are removed from the stage, and the original container is removed from the stage and then deleted. The bitmap is the only remaining “graphic” on the stage, aside from the player.

This yields far better performance than allowing all 60,000+ tiles to be rendered individually during gameplay; however, the framerate still reduces as the number of tiles is increased. This makes no sense, as all the tiles are added to a single bitmap that is always the same size, regardless of the amount of tiles.

With 20,000 tiles during generation, the game runs at the full FPS, but with 60,000 it runs relatively choppy, probably around 4-5 FPS.

I’ve removed collision detection and any/every script that runs through the tile array to rule out the possibility that some other CPU intensive part of the script is lagging the framerate.

Any idea why, despite the fact that all tiles have been removed from the stage and their container is deleted, the game is still running slow even though the background bitmap contains the same amount of data regardless of the number of tiles generated?

Here is the last part of the level generation algorithm which converts the container movieclip to a bitmap and then removes all the tiles:

        var temp_bitmap_data:BitmapData = new BitmapData(this.stage_background_mc.width,this.stage_background_mc.height);

        temp_bitmap_data.draw(this.stage_background_mc);

        this.stage_background_bitmap = new Bitmap(temp_bitmap_data);


        main_class.main.stage.addChild(this.stage_background_bitmap);

        for (var block in blocks_array)
        {

             //every block in blocks_array has a child that is the actual graphic of the tile
             blocks_array[block]["block"].removeChild(blocks_array[block]["block"].getChildAt(0));

            if (blocks_array[block]["type"] == "bg_block")
            {
                this.stage_background_mc.removeChild(blocks_array[block]["block"]);
                blocks_array[block]["block"] = null;
            }
            if (blocks_array[block]["type"] == "path_block")
            {

                //path_blocks have a second child in addition to the first one that's already been removed. the second child is the only other child
                blocks_array[block]["block"].removeChild(blocks_array[block]["block"].getChildAt(0));
                this.stage_background_mc.removeChild(blocks_array[block]["block"]);             

            }




        }

        this.stage_background_mc = null;

[Edit]
Here is a picture of the game to give you a better idea of what’s going on:
the game level

[Update:]

Even removing the final created bitmap from the stage, ending up with only 1 child on stage, and setting that removed bitmap to null doesn’t improve the speed.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T07:12:26+00:00Added an answer on June 5, 2026 at 7:12 am

    A couple of thoughts.

    First, you’re sorta half taking advantage of AS3’s quick work with blitting. You’ve got the right idea about having only one single Bitmap on the stage, but the steps before (adding DisplayObjects to a MovieClip and the doing draw on that MovieClip) isn’t the fastest process. For one thing, BitmapData.draw is slower than BitmapData.copyPixels (here is a post on that). One of the best ways to get speed is to pre-blit all of your graphics, and store them as BitmapData. Then, keep Object references (containing position, etc) for each graphic. In your render loop, run through each object, and use copyPixels to copy the graphic’s pixel information to the appropriate positon in your single, on-stage Bitmap. This way, all slow BitmapData.draw commands have happened upfront, and now you are just pushing pixels, which Flash is really fast at.

    That process isn’t without its downsides, however. For instance, you can’t do easy transforms with it. You’d have to pre-blit all frames of a rotation, for instance, in order to rotate the individual graphic (since you can’t rotate a BitmapData, and you aren’t using draw on a DisplayObject). Still, it is mighty fast if you can live with the limitations.

    Here is a post that serves as a tutorial of the process I explained above. It is old, but informative none-the-less.

    Finally, 60,000 is a very large number. Flash isn’t exactly a “speed demon.” No matter how optimized, eventually you’ll hit a limit. Just something to keep in mind.

    Oh, and this additional post gives some great tips on performance in Flash.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.