
Код AS3:
public var kom_zt:Timer;
public var komZm:Bitmap;
public var komZm1:Bitmap;
public var komZmSprite:Sprite;
public var komZmB:Body;
//...//
for(var k:int=0; k<5; k++){
komZm=new Bitmap();
komZm.bitmapData = new BitmapData(Atlas.atlasXML.sprite[25].@w, Atlas.atlasXML.sprite[25].@h);
komZm.bitmapData.copyPixels(Preloader.ATLAS,
new Rectangle(Atlas.atlasXML.sprite[25].@x, Atlas.atlasXML.sprite[25].@y, Atlas.atlasXML.sprite[25].@w, Atlas.atlasXML.sprite[25].@h),
new Point(0, 0));
komZm.smoothing=true;
komZm1=new Bitmap();
komZm1.bitmapData = new BitmapData(Atlas.atlasXML.sprite[26].@w , Atlas.atlasXML.sprite[26].@h);
komZm1.bitmapData.copyPixels(Preloader.ATLAS,
new Rectangle(Atlas.atlasXML.sprite[26].@x, Atlas.atlasXML.sprite[26].@y, Atlas.atlasXML.sprite[26].@w, Atlas.atlasXML.sprite[26].@h),
new Point(0, 0));
komZm1.smoothing=true;
komZmSprite=new Sprite;
komZmSprite.addChild(komZm);
komZmSprite.addChild(komZm1);
komZm.x -= komZm.width/2;
komZm.y -= komZm.height/2;
komZm1.x -= komZm1.width/2;
komZm1.y -= komZm1.height/2;
Mir.addChild(komZmSprite);
komZmSprite.width=(stage.stageWidth*93)/768;
komZmSprite.scaleY=komZmSprite.scaleX;
komZmB=new Body(BodyType.DYNAMIC, new Vec2(0, 0));
komZmB.isBullet=true;
komZmB.shapes.add(new Polygon(Polygon.box(komZmSprite.width, komZmSprite.height), Material.steel()));
komZmB.position.setxy(stage.stageWidth/5+((stage.stageWidth*3)/5)*Math.random(), stage.stageHeight/10);
komZmB.allowRotation=false;
komZmB.space=space;
komZmB.userData.graphic=komZmSprite;
komZmB.velocity.setxy(stage.stageWidth/100, stage.stageHeight/100);
//после того как выполнилась функция с циклам запускаю таймер//
private function anim():void{
kom_zt = new Timer(50);
kom_zt.start();
kom_zt.addEventListener(TimerEvent.TIMER, kom_ztf);
};
private function kom_ztf (e:TimerEvent):void{
if((kom_zt.currentCount & 1) == 0) {
komZm1.visible=true;komZm.visible=false;
} else{
komZm.visible=true;komZm1.visible=false;}