Denna kod:
var l:Number=pile[i].num;
trace("num:"+l);
var j:Number=0;
for(j=0;j<l;j++){
trace("push:"+pile[i].value+", j:"+j+", l:"+l+", j < l:"+(j<l));
trace("typeof j:"+typeof(j)+", typeof l:"+typeof(l));
}
ger denna output:
num:3
push:0.05, j:0, l:3, j < l:true
typeof j:number, typeof l:number
push:0.05, j:1, l:3, j < l:true
typeof j:number, typeof l:number
push:0.05, j:2, l:3, j < l:true
typeof j:number, typeof l:number
push:0.05, [b][3][red]j:3, l:3, j < l:true[/red][/3][/b]
typeof j:number, typeof l:number
Testar jag istället med att köra:
var l:Number=3;
trace("num:"+l);
var j:Number=0;
for(j=0;j<l;j++){
trace("push:"+pile[i].value+", j:"+j+", l:"+l+", j < l:"+(j<l));
trace("typeof j:"+typeof(j)+", typeof l:"+typeof(l));
}
Så får jag:
num:3
push:5, j:0, l:3, j < l:true
typeof j:number, typeof l:number
push:5, j:1, l:3, j < l:true
typeof j:number, typeof l:number
push:5, j:2, l:3, j < l:true
typeof j:number, typeof l:number
Alltså...värdet av "pile.num" är av typen nummer med värdet 3, men ändå så anser Flash att det är mindre än 3.
Ändrar jag så jag hårdkodar det till 3 så anser Flash att det inte är mindre än 3.
"l" och "j" är varibler deklarerade lokalt i en funktion.
Detta händer inte vanligtvis utan vanligtvis fungerar det som väntat...exempel på hur det ser ut då jag kör hela funktionen med lite olika värden:
num:3
push:0.01, j:0, l:3, j < l:true
typeof j:number, typeof l:number
push:0.01, j:1, l:3, j < l:true
typeof j:number, typeof l:number
push:0.01, j:2, l:3, j < l:true
typeof j:number, typeof l:number
num:3
push:0.05, j:0, l:3, j < l:true
typeof j:number, typeof l:number
push:0.05, j:1, l:3, j < l:true
typeof j:number, typeof l:number
push:0.05, j:2, l:3, j < l:true
typeof j:number, typeof l:number
push:0.05, j:3, l:3, j < l:true
typeof j:number, typeof l:number
num:1
push:0.5, j:0, l:1, j < l:true
typeof j:number, typeof l:number
num:2
push:1, j:0, l:2, j < l:true
typeof j:number, typeof l:number
push:1, j:1, l:2, j < l:true
typeof j:number, typeof l:number
num:1
push:5, j:0, l:1, j < l:true
typeof j:number, typeof l:number
num:2
push:100, j:0, l:2, j < l:true
typeof j:number, typeof l:number
push:100, j:1, l:2, j < l:true
typeof j:number, typeof l:number
num:3
push:1000, j:0, l:3, j < l:true
typeof j:number, typeof l:number
push:1000, j:1, l:3, j < l:true
typeof j:number, typeof l:number
push:1000, j:2, l:3, j < l:true
typeof j:number, typeof l:number
:q
Om någon har en idé om hur detta är möjligt vorde det kanon, men jag är mest ute efter medlidande :(