Флешка
http://medveduka.ru/flasher/engineertestforflasher.html запускать через дебуг плеер.
на клавишу 1 происходить просто действия на клавишу 2 после действия вызывается System.gc()
урезал большую часть кода, теперь данный баг или мою ошибку возможно уловить только при принудительном вызове GC
исходник
http://medveduka.ru/flasher/engineertestforflasher.rar

Код AS3:
package
{
import flash.display.Sprite;
import flash.events.KeyboardEvent;
public class EngineerTestForFlasher extends Sprite
{
public function EngineerTestForFlasher()
{
Repository.hero= new Hero;
Repository.gamescreen.start();
new Maps;
stage.addEventListener(KeyboardEvent.KEY_DOWN,KeyboardControl.KeyDown);
stage.addEventListener(KeyboardEvent.KEY_UP,KeyboardControl.KeyUp);
this.addChild(Repository.gamescreen);
this.addChild(new FPSMemCounter(0));
MapLive.loadMap(Maps.maps[0]);
}
}
}

Код AS3:
package
{
public class Config
{
public static var gridLength:int=80;
public static var gridSize:int=70;
public static var mapSizeX:int=2880;
public static var mapSizeY:int=2880;
public function Config()
{
}
}
}

Код AS3:
package
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.Matrix;
import flash.geom.Rectangle;
public class GameScreen extends Sprite
{
public static var corpsesData:BitmapData = new BitmapData(Config.mapSizeX,Config.mapSizeY ,true,0);;
public static var corpses:Bitmap= new Bitmap(corpsesData);
public static var background:Sprite = new Sprite();
public static var recForClean:Rectangle = new Rectangle(0,0,Config.mapSizeX,Config.mapSizeY);
private var matrix:Matrix = new Matrix;
public function GameScreen()
{
}
public function start():void
{
this.addEventListener(Event.ENTER_FRAME,onFrame);
this.addChild(background);
this.addChild(corpses);
this.addChild(Repository.hero);
}
private function onFrame(e:Event):void
{
if(Hero.X<=Config.mapSizeX-800/2&&Hero.X>=800/2)
{
x-=int(Hero.X+x-800/2);
}
if(Hero.Y<=Config.mapSizeY-600/2&&Hero.Y>=600/2)
{
y-=int(Hero.Y+y-600/2);
}
}
}
}

Код AS3:
package
{
import flash.display.MovieClip;
import flash.display.Sprite;
public class Hero extends MovieClip
{
public static var X:Number=100;
public static var Y:Number=100;
public static var HP:int;
public static var SPEED:Number=4;
private var ROTATION:Number=0;
public static var angle:Number;
public static var keyLeft:Boolean;
public static var keyRight:Boolean;
public static var keyUp:Boolean;
public static var keyDown:Boolean;
public static var size:int=15;
public function Hero()
{
this.addEventListener(Event.ENTER_FRAME,onFrame);
var img:Sprite = new Sprite;
img.graphics.beginFill(0);
img.graphics.drawCircle(0,0,size);
this.addChild(img);
X=100;
y=100;
}
private function onFrame(e:Event):void
{
ROTATION=-1;
if(keyUp)ROTATION=0.5*Math.PI;
if(keyLeft)ROTATION=0;
if(keyRight)ROTATION=Math.PI;
if(keyDown)ROTATION=1.5*Math.PI;
if(keyUp&&keyLeft)ROTATION=0.25*Math.PI;
if(keyUp&&keyRight)ROTATION=0.75*Math.PI;
if(keyDown&&keyLeft)ROTATION=1.75*Math.PI;
if(keyDown&&keyRight)ROTATION=1.25*Math.PI;
if(ROTATION!=-1)
{
var nextX:int=X-Math.cos(ROTATION) * SPEED;
var nextY:int=Y-Math.sin(ROTATION) * SPEED;
X=nextX;
Y=nextY;
}
if(this.x!=X)this.x=X;
if(this.y!=Y)this.y=Y;
}
}
}

Код AS3:
package
{
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.system.System;
public class KeyboardControl
{
public function KeyboardControl()
{
}
public static function KeyDown(e:KeyboardEvent):void
{
if (e.keyCode==87||e.keyCode==38) Hero.keyUp=true;
if (e.keyCode==83||e.keyCode==40) Hero.keyDown=true;
if (e.keyCode==65||e.keyCode==37) Hero.keyLeft=true;
if (e.keyCode==68||e.keyCode==39) Hero.keyRight=true;
if(e.keyCode==49)
{
MapLive.loadMap(Maps.maps[0]);
}
if(e.keyCode==50)
{
MapLive.loadMap(Maps.maps[0]);
System.gc();
}
}
public static function KeyUp(e:KeyboardEvent):void
{
if (e.keyCode==87||e.keyCode==38) Hero.keyUp=false;
if (e.keyCode==83||e.keyCode==40) Hero.keyDown=false;
if (e.keyCode==65||e.keyCode==37) Hero.keyLeft=false;
if (e.keyCode==68||e.keyCode==39) Hero.keyRight=false;
}
}
}

Код AS3:
package
{
import flash.display.Bitmap;
import flash.display.MovieClip;
import flash.events.TimerEvent;
import flash.geom.Matrix;
import flash.geom.Rectangle;
import flash.system.System;
import flash.utils.Timer;
public class MapLive
{
public static var mapLive:MapLive = new MapLive;
public static var timer:Timer = new Timer(1);
public static var map:XML;
private static var ael:Boolean=false;
public function MapLive()
{
}
public static function loadMap(mapForCopy:XML):void
{
if(!ael)timer.addEventListener(TimerEvent.TIMER,onTimer);
ael=true;
timer.reset();
timer.start();
timer.delay=1;
map=mapForCopy.copy();
GameScreen.corpsesData.lock();
GameScreen.corpsesData.fillRect(new Rectangle(0,0,Config.mapSizeX,Config.mapSizeY),0);
GameScreen.corpsesData.unlock();
var t:Img_texture= new Img_texture;
t.gotoAndStop(int(map.backgroundFill));
var bt:Bitmap;
bt= t.getChildAt(0)as Bitmap;
GameScreen.background.graphics.clear();
GameScreen.background.graphics.beginBitmapFill(bt.bitmapData);
GameScreen.background.graphics.drawRect(0,0,Config.mapSizeX,Config.mapSizeY);
mapForCopy=null;
bt=null;
t=null;
}
private static function onTimer(e:TimerEvent):void
{
timer.delay=1000;
for each( var command:XML in map.command)
{
var ifSum:int=0;
var ifSumTrue:int=0;
for each( var commandIf:XML in command.IF)
{
for each( var time:XML in commandIf.time)
{
if(timer.currentCount>int(time))ifSumTrue++
}
ifSum++;
}
if(ifSum==ifSumTrue && command.count>0 &&(timer.currentCount==0||timer.currentCount%command.interval==0||command.interval==0))
{
for each(var addBackgroundUp:XML in command.addBackgroundUp)
{
var b:MovieClip = new Img_backgroundUp();
b.gotoAndStop(int(addBackgroundUp.type));
var m:Matrix= new Matrix();
m.rotate(addBackgroundUp.angle * Math.PI/180);
m.translate(addBackgroundUp.x,addBackgroundUp.y);
GameScreen.corpses.bitmapData.lock();
GameScreen.corpses.bitmapData.draw(b,m);
GameScreen.corpses.bitmapData.unlock();
command.count=int(command.count)-1;
b=null;
m=null;
}
}
}
}
}
}

Код AS3:
package
{
public class Maps
{
public static var maps:Array = new Array;
public function Maps()
{
maps[0]=<map>
<backgroundFill>1</backgroundFill>
<command>
<interval>1</interval>
<count>1</count>
<addBackgroundUp>
<x>100</x>
<y>100</y>
<angle>90</angle>
<type>1</type>
<id>1</id>
</addBackgroundUp>
</command>
<command>
<interval>1</interval>
<count>1</count>
<addBackgroundUp>
<x>100</x>
<y>200</y>
<angle>90</angle>
<type>1</type>
<id>1</id>
</addBackgroundUp>
</command>
<command>
<interval>1</interval>
<count>1</count>
<addBackgroundUp>
<x>300</x>
<y>200</y>
<angle>90</angle>
<type>1</type>
<id>1</id>
</addBackgroundUp>
</command>
</map>
}
}
}

Код AS3:
package
{
public class Repository
{
public static var hero:Hero= new Hero;
public static var gamescreen:GameScreen= new GameScreen;
public function Repository()
{
}
}
}