development <<< haxe syntax
  1. number sequence generator (range Array<Int> generator)
  2. 2d Array syntax
  3. one line FlxTimer
  4. conditional compilation (targeting mobile desktop web ios)
  5. $type | Type.typeof | Types | Reflect
  6. FlxSprite
  7. haxeflixel http requests, response, open url, html parser
  8. haxeflixel FlxG.save
  9. variable sign | if short form | "+=" vs "+ ="
  10. Array slice срез последовательности масива
  11. Array move slice сдвинуть срез
  12. Array move element сдвинуть элемент
  13. for loop
  14. haxeflixel button callback with parameters

  1. number sequence generator (range Array generator)
  2. Array comprehension
    var x:Array<Int>=[for (i in 0...10) i];// [0,...,9]
    x.reverse();// [9,...,0]
    // "trace(x.reverse());" create error because reverse():Void return Void
    x.reverse(); trace(x); // work done

  3. 2d Array syntax
  4. var t = [
            [1.2,1.2,1.2],
            [2.2,2.2,2.2]
        ];
    trace(t);
    $type(t); // can't use for compare "if ($type(t) == ".
    It will trace the variable type into console,
    when "lime build android" etc compile process
    type system type interface var t = []; t.push([1.2,1.2,1.2]); t.push([2.2,2.2,2.2]); trace(t); var t:Array<Array<Float>> = new Array(); t.push([1.2,2]); t.push([2,3/2]); trace(t);

  5. one line FlxTimer
  6. mytimer.start(3,function(t:FlxTimer):Void{FlxG.switchState(new PS());});
    дополнительный синтаксис для таймеров в стороку (не проверено, со слов gama11)
    mytimer.start(3,function(t) FlxG.switchState(new PS())) would work too
    or mytimer.start(3, t -> FlxG.switchState(new PS())) in haxe 4
  7. conditional compilation (targeting mobile desktop web ios)

  8. haxeflixel conditionals
    compiler conditionals
    
    #if (web || desktop)
    //code ...
    #elseif android
    //code ...
    #elseif ios
    //code ...
    #else
    //code ...
    #end
    

  9. $type | Type.typeof | Types | Reflect
  10. $type show the type only in compiling process. Can't be used to compare data.
    $type(x);

    Type.typeof can be used to compare data.
    var x:Int=1;
    var typex:Type.ValueType=Type.ValueType.TInt;
    trace(Type.typeof(x)==typex); // -> true
    
    or
    import Type.ValueType;
    import Type.typeof;
    var x:Int=1;
    trace(typeof(x)==TInt); // -> true
    
    Type.ValueType. TNull TInt TFloat TBool TObject TFunction TClass(c:Class<Dynamic>) TEnum(e:Enum<Dynamic>) TUnknown
    Types
    Type groups: Class instance | Enum instance | Structure | Function | Dynamic | Abstract | Monomorph .
    Basic types: Bool(true, false) | Int(-1, 0, 1, 0xFF0000) | Float(-1.0, 0.0, 1.0, 1e10) .
    numeric operators: Arithmetic(++ -- + - * / %) | Comparison(== != < <= > >=) | Bitwise(~ & | ^ << >> >>>) | Bool(&& || !)
    Reflect isEnumValue isFunction isObject callMethod compare compareMethods
    Using Reflect and Type examples of typeof and reflect syntax
  11. FlxSprite
  12. mysprite.fill(FlxColor.TRANSPARENT);
    clear the "var mysprite:FlxSprite" from makeGraphic objects (not checked, from gama11)
  13. haxeflixel http requests, response, open url, html parser
  14. http requests, response
    import haxe.Http;
    ...
    FlxG.log.redirectTraces = true; // trace in debug window of worked app, which can be opened "\" or "F2" keyboard button
    var testserver:Bool=true;
    var serverlink:String;
    if (Main.testserver){serverlink="http://127.0.0.1:8000/myapp/";}
    else {serverlink="http://mysite.pythonanywhere.com/myapp/";}
    var req:Http = new Http(serverlink);
    req.setParameter("appname","ClockworkPlanetPuzzle");
    req.setParameter("x","value always string");
    req.request( true ); // false=GET, true=POST . DESKTOP WORK DONE ONLY CPP TAGETING. NEKO AND HTML5 IS FALL
    trace(req.responseData); // string data. Trace to show data inside vscode "output" tab or app debug window "\" or "F2"
    

    open url
    import flixel.FlxG;
    ...
    FlxG.openURL(serverlink,"_blank"); //without "_blank" work too
    

    html parser
    Install library use haxelib. Console
    haxelib install HtmlParser
    "Enter", wait. If all done then next.
    Add to haxeflixel "Project.xml" (for example into Libraries section)
    <haxelib name="HtmlParser" />
    Add to *.hx file
    import htmlparser.HtmlParser;
    compile once ("Ctrl+Shift+p" for vscode or "lime build cpp -debug" use console from "Project.xml" directory), then can use it with intellisense autocomplete.
  15. haxeflixel FlxG.save
  16. The calling to FlxG.save, inside Main.hx public function new() method, must be placed/realised only after creating the game object, for example:
    _game = new FlxGame(720, 1280, PS, true);
    this.usersave_load();
    addChild(_game);
    or will be raised error "Null object reference", after compiling when app try to run
    edit Main.hx for standart haxeflixel project
    import flixel.FlxG;
    import flixel.util.FlxSave;
    
    class Main extends Sprite
    {
    	public static var x:Float=0;
    	public static var y:Float=0;
    	public static var ss:FlxSave;
    	
    	public static function saveall():Void
    	{
    		ss=FlxG.save;
    		ss.data.x=x;
    		ss.data.y=y;
    		ss.flush();
    	}
    	
    	public static function loadall():Void
    	{
    		ss=FlxG.save;
    		if(ss.data.x != null){
    			x=ss.data.x;
    			y=ss.data.y;
    		}
    	}
    
    later, inside PlayState.hx etc, use syntax
    Main.saveall(); // to save data
    Main.loadall(); // to load data
    
    that delete saved data from windows, find and delete the "appname" folder, for example, placed "C:\Users\user\AppData\Roaming\HaxeFlixel"(that's the location. But only if you left the "company" in project.xml as "HaxeFlixel" in <app></app>). That erase saved data from code, use "ss.data.x=null;ss.data.y=null;ss.flush();" syntax or use "ss.erase();ss.flush();" (not tested,was some problems with same syntax, look like bug 1302)
  17. variable sign | if short form | "+=" vs "+ ="
  18. var myvar:Int=0;
    var myvarsign:Int=(myvar<0)?-1:1;
    myvar+=1; //work good("myvar+ =1;"create error)
    

  19. Array slice срез последовательности масива
  20. var x:Array<Int>[1,2,3].slice(1);// -> [2,3]
    var x:Array<Int>[1,2,3].slice(-2);// -> [2,3]
    

  21. Array move slice сдвинуть срез
  22. var x:Array<Int>=[1,2,3,4,5];
    x=x.concat(x.splice(0,2)); // -> x=[3,4,5,1,2]
    x=x.splice(3,2).concat(x); // -> x=[1,2,3,4,5]
    

  23. Array move element сдвинуть элемент
  24. Using arrays
    var x:Array<Int>=[1,2,3,4,5];
    x.push(x.splice(0,1)[0]); // -> x=[2,3,4,5,1]
    x.push(x.shift()); // -> x=[3,4,5,1,2]
    x.unshift(x.splice(4,1)[0]) // -> x=[2,3,4,5,1]
    x.insert(0,x.splice(4,1)[0]); // -> x=[1,2,3,4,5]

  25. for loop
  26. for (i in 0 ... 3) //0 1 2
    for (i in [1,3,2]) //1 3 2

  27. haxeflixel button callback with parameters
  28.     var abtn_auto:Array = []; //array for keep buttons, can be good
        var ax_auto:Array = [...];
        var ay_auto:Array = [...];
        var w_auto:Int = 240;
        var h_auto:Int = 128;
        private function auto_callback(x):Void{ trace(x); }
        private function create_auto():Void{
            for (i in 0...9){
                var b:FlxButton = new FlxButton(ax_auto[i], ay_auto[i], "",function():Void{auto_callback(i);});
                b.loadGraphic("assets/images/calc/240128glass_calc_auto.png", false,w_auto,h_auto);
                abtn_auto.push(b);
                add(abtn_auto[i]);
            }
        }