for (i in 0...15)
{
var symbol:SymbolGame = new SymbolGame();
var d:Int = 0;
var l:Float = i / 3;
d = Math.floor(l);
var comb:Array<Int> = getCombination(d);
var position:Int = pos[d];
var z:Int = 0;
if (Std.int(position) + Std.int(j) > Std.int(comb.length) - 1)
{
z = Std.int(position) + Std.int(j) - Std.int(comb.length);
}
else z = Std.int(position) + Std.int(j);
symbol.setStandardImage( comb[z] );
...
}
…public function setStandardImage(face:Int):Void
{
if (face > -1 ) this.currentFace = Std.int(face) + 1;
Thx for u answer.
Lime/haxe/openfl - latest version
Please test my full code, not simple without Std.int
If it needed comb = [[1,2,3,4,35],[1,2,3,4,45],[1,2,3,4,55]…]]; for example
and pos[d] = 1 or 2 or 3 … and so on
When i test
if (position + j > comb.length - 1)
{
z = position + j - comb.length;
}
else z = position + j;
public function setStandardImage(face:Int):Void
{
if (face > -1 ) this.currentFace = face + 1;
trace(currentFace) // some1
// also if face = 0 for example, and current = 10 , aseets also crushes, but symbol_10 i have
this._currentPic = AssetsManager.getImage("symbol_" + this.currentFace
}
and finally after set
this.currentFace = Std.int(face) + 1;
thats works
((((
Since JavaScript has no runtime types, it won’t complain if you type something the wrong way.
Here’s an example:
var a:Int = cast "100";
var b = a + 100;
trace (b);
…on JavaScript, this will trace “100100”, and on C++, it will probably crash horribly
Haxe is strongly typed, so it guards against this, but if you ever use Dynamic an unsafe cast, you open yourself up to the risk that you may get the wrong type. Use caution
For example:
var data:Dynamic = { a: "100" };
var a:Int = data.a;
trace (a + 100);
This will produce the same problem. data is Dynamic, so the compiler assumes when you run a:Int = data.a that data.a really is an integer. This would work better if it was really a String
var data:Dynamic = { a: "100" };
var a = Std.parseInt (data.a);
trace (a + 100);
The great news is this is uncommon in Haxe development, but is much more common in plain JavaScript
miltoncandelero - no its no chance, because its class field typed Int
singmajesty - I dont understand u. What im doing wrong? I have no Dynamic , also I have no cast string to Int for example. In my code all variables has type Int or Float or Array Int - no String
but…
before i do
var cmb:Array<String> = e.data.combs.split("|");
var fin:Array<Array<Int>> = [];
var sml:Array<Int> = [];
for (i in 0...cmb.length)
{
sml = cast cmb[i].split(",");
fin.push(sml);
}
this._model.combinations = fin;
Maybe thats broke the code later? And fin != Array Int now for JS ?
If its true - please show me the way, how cast dynamic vars to real int, on example my last code shown