A ni ovo ne radi. Ima li iko ideju kako i zasto ????????????????
Code:
package {
import flash.display.Sprite;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFieldType;
import flash.utils.Timer;
//import flash.display.*;
public class gameLoop1 extends Sprite
{
private var i_int:int=0;
private var zbir_int:int=0;
private var counter_int:int=0;
private var time_txt:TextField=new TextField();
public var again:Event=new Event("_AGAIN",false,true);
public var reload:Event=new Event("_RELOAD",false,true);
public var start:Event=new Event("_START",false,true);
public var gameLoopStartTimer:Timer; // = new Timer(10, 2050); // 10 ms, 22250 times repeat
public function gameLoop1() //constructor
{
stage.addEventListener(KeyboardEvent.KEY_UP, startGame_f);
stage.addEventListener(start.type, f1,false,0,false);
stage.addEventListener(again.type, f2,false,0,false);
stage.addEventListener(reload.type,f1,false,0,false);
//this.addEventListener("_AGAIN",f1,false,0,false);
//this.addEventListener("_RECALL",f2);
//this false e error
//stage true e error
time_txt.type = TextFieldType.DYNAMIC;
time_txt.border = true;
time_txt.background = true;
time_txt.backgroundColor = 0xD6D3CE;// 0xFFFF66;
time_txt.width = 160; //px
time_txt.height = 450;
time_txt.autoSize = TextFieldAutoSize.LEFT; //size from left
time_txt.wordWrap = true;
time_txt.text = "Initializing! Please wait.";
addChild(time_txt);
} //end of constructor
private function startGame_f(e:KeyboardEvent):void
{
e.stopImmediatePropagation();
e.preventDefault();
if(e.keyCode==32)
{
dispatchEvent(start); //calls f1();
stage.removeEventListener(start.type,f1);
}
}
private function f1(e:Event):void
{
e.stopPropagation();
e.preventDefault();
e.stopImmediatePropagation()
counter_int++;
for(i_int=0;i_int<1000;i_int++)
{
zbir_int=zbir_int+i_int;
}
time_txt.text = "loop counter: "+counter_int+
"\nzbir: "+zbir_int+
"\n"+start.type;
/*
stage.addEventListener(again.type, f2,true,0,false);
stage.addEventListener(reload.type,f1,true,0,false);
*/
stage.removeEventListener(reload.type, f1);
dispatchEvent(again); //calls f2();
} //end of f1
public function f2(e:Event):void
{
e.preventDefault();
e.stopImmediatePropagation();
e.stopPropagation();
/*
stage.addEventListener(reload.type,f1,true,0,false);
*/
stage.addEventListener(reload.type, f1,true,0,false);
stage.removeEventListener(again.type,f2);
dispatchEvent(reload); //calls f1();
}
} //end of class
} // end of package
I'm not in this world to live up to your expectations and you're not in this world to live up to mine.