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 7713059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:46:33+00:00 2026-06-01T01:46:33+00:00

I have a game loop written in Haxe/Flash. For some reason it slows down

  • 0

I have a game loop written in Haxe/Flash. For some reason it slows down over time. At first it runs reasonably, but my laptop fan starts spinning up and it gets slower and slower. Why would this happen?

import flash.display.StageDisplayState;
import flash.display.StageScaleMode;
import flash.display.MovieClip;
import flash.display.BitmapData;
import flash.display.Stage;
import flash.events.Event;
import flash.geom.Matrix;

class Driver {
    static var scale:Int = 8;
    static var stage:Stage
        = flash.Lib.current.stage;
    static var drv:Driver;
    static var mc:MovieClip
        = flash.Lib.current;

    var x:Int;

    var w:Int;
    var h:Int;
    var bbuf:BitmapData;
    var mtx:Matrix;

    private function tick() {
        x = (x + 1) % Std.int(w/scale);
    }

    private function draw() {
        bbuf.setPixel(x - 1, 10, 0);
        bbuf.setPixel(x, 10, 0xff0000);
    }

    private function flip() {
        mc.graphics.beginBitmapFill(bbuf, mtx);
        mc.graphics.moveTo(0, 0);
        mc.graphics.lineTo(w, 0);
        mc.graphics.lineTo(w, h);
        mc.graphics.lineTo(0, h);
        mc.graphics.endFill();
    }

    private function OnEnter(e:Event) {
        tick();
        draw();
        flip();
    }

    public function new() {
        mtx = new Matrix();
        mtx.scale(scale, scale);
        w = stage.stageWidth;
        h = stage.stageHeight;
        mc = flash.Lib.current;
        bbuf = new BitmapData(
            Std.int(w/scale), Std.int(h/scale),
            false, 0);

        if (w % scale != 0) {
            trace("width not a multiple of "
                + "scale factor");
            return;
        }
        if (h % scale != 0) {
            trace("height not a multiple of "
                + "scale factor");
            return;
        }
        stage.addEventListener(
            Event.ENTER_FRAME, OnEnter);
    }

    static function main() {
        drv = new Driver();
    }
}

The program shows a red dot moving across the screen horizontally. Over the course of a minute or two the dot gets slower and slower. I have tried this on two separate systems (Windows 7, Ubuntu 11).

  • 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-01T01:46:34+00:00Added an answer on June 1, 2026 at 1:46 am

    Try to clear graphics before beginBitmapFill. I found same topic but did not find in documentation that beginBitmapFill may leak.

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

Sidebar

Related Questions

Im trying to create a NSThread game loop, i have some of the time
I have an idea of organising a game loop. I have some doubts about
If I have some basic game loop in a thread, like this: public void
I have recently begun to develop a game in Haxe which targets the Flash
I have a game that currently runs under Windows and Mac OS X and
I have this game with some variety of textures. Whenever I draw a texture
I have a simple iPhone game consisting of two threads: the main game loop
I have an application which has a loop, part of a Scheduler, which runs
I have a game site developed using flash and php. The php code contains
I have some code written in Ruby 1.9.2 patch level 136 and I'm have

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.