Really odd bug..

Monkey Targets Forums/Flash/Really odd bug..

Paul - Taiphoz(Posted 2012) [#1]
Hay..

I have just come accross a really odd bug, which I am not sure is with my code or monkey so will post this here first.

I'n a nut shell, I have a level array which holds the tile numbers for each level, which I then use to render out that level drawing the appropriate tile, nothing fancy here.

When I build in Html5, GLFW and XNA , the level loads fine, and renders the level fine as well, but when I set the target to flash, the game runs, but when I load the level its all messed up, the whole level seems to be filled with tile 0.

any ideas?


Paul - Taiphoz(Posted 2012) [#2]
problem seems to be here..

I flung in a print to check the length of the level being loaded, in flash this returns or prints ZERO. so for some reason on that target, its not getting the data. ?

Works in Html5, GLFW, XNA , cant test the others, fails in Flash.

[monkeycode]
Method LoadStage(_stage:Int=1,_wave:Int=1)



CacheAliens(stage)

'If stage<>1 Then AssertError("Level Fail")

'TestSpawns()

Self.stage=_stage
Self.wave=_wave


Self.StageSpeed=.7
Local tmpImage:Image
Self.offsetx=-16

Local LevelIN:String


LevelIN = LoadString("level/Stage_"+String(_stage)+"/Stage.txt")
Print "Level Length "+LevelIN.Length

Local SpawnIN:String
SpawnIN = LoadString("level/Stage_"+String(_stage)+"/wave_"+_wave+".txt")



Self.BackGround = game.images.LoadAnim("level/stage_"+String(_stage)+"/stagebg_"+String(_stage)+".png", 480,200,6,tmpImage,True)
Self.BackGroundOffset = 0
Self.BackGroundStep = 0

game.images.LoadAnim("level/stage_"+String(_stage)+"/StageTiles_"+String(_stage)+".png", 128, 128, 80, tmpImage,True)
Self.StageTiles = game.images.Find("StageTiles_"+String(_stage))



Local loop:Int = 0
For Local NewGrid:String = Eachin LevelIN.Split(",")
If loop<500
Self.grid[loop]=Int(NewGrid)
loop+=1
End If
Next

Local bit:Int=1
Local id:Int=0
Local trig:Int=0
Local cnt:Int=0
Local unit:Int =0
For Local value:String = Eachin SpawnIN.Split(",")

'Print "Bit ="+bit


Select bit
Case 1
unit=Int(value)
Case 2
id=Int(value)
Case 3
trig=Int(value)
Case 4
cnt=Int(value)
End Select

If bit=4 Then
AddWave(unit,id,trig,cnt)
'Print "Adding Wave ["+id+","+trig+","+cnt+"]"
bit=0
End If

bit=bit+1
bit = bit Mod 5

Next

'ok level is loaded, now set the values in this levels star array.

User.onestar[_stage][_wave]=self.scorepool/2
User.twostar[_stage][_wave]=self.scorepool-(self.onestar/2)
User.threestar[_stage][_wave]=self.scorepool+100

self.onestar = self.scorepool/2
self.twostar = self.scorepool-(Self.onestar/2)
self.threestar = self.scorepool+100

End Method
[/monkeycode]


muddy_shoes(Posted 2012) [#3]
Nothing obviously wrong with the code.

Did it ever work on Flash?
Have you checked the stage number?
Have you verified that the file is referenced as you'd expect in the embeds section of the translated AS file?
Have you tried just deleting the build directory and recompiling?


Paul - Taiphoz(Posted 2012) [#4]
yeah it was working, the last time I recall a flash build was maybe a week ago, I always test and build on html5 I only try a flash build every now and then.

Yeah deleted the build folder.

I have not checked the stage number but if that was wrong then it would not also be wrong when built for html5, or glfw ?

hmm... that made me think is there anything different about the way that flash handles a select case statement ?


Paul - Taiphoz(Posted 2012) [#5]
dont really know action script but that looks like its embedding the right path.

public static var _8graphics3set3png:Class;
[Embed(source="data/graphics/sprites.png")]
public static var _8graphics7sprites3png:Class;
[Embed(source="data/level/stage_1/Stage.txt",mimeType="application/octet-stream")]
public static var _5level7stage_15Stage3txt:Class;
[Embed(source="data/level/stage_1/wave_1.txt",mimeType="application/octet-stream")]
public static var _5level7stage_16wave_13txt:Class;
[Embed(source="data/level/stage_1/wave_10.txt",mimeType="application/octet-stream")]
public static var _5level7stage_17wave_103txt:Class;
[Embed(source="data/level/stage_1/wave_11.txt",mimeType="application/octet-stream")]
public static var _5level7stage_17wave_113txt:Class;
[Embed(source="data/level/stage_1/wave_12.txt",mimeType="application/octet-stream")]



muddy_shoes(Posted 2012) [#6]
Is it maybe the case of your stage directory?

[monkeycode]LevelIN = LoadString("level/Stage_"+String(_stage)+"/Stage.txt")[/monkeycode]

Whereas the embedded file shows the directory as "stage_".


Paul - Taiphoz(Posted 2012) [#7]
found it..

Flash is actually case sensitive even with its folder path's so I was looking in /level/Stage/stage_1 when the actual folder name was /level/stage/stage_1 so looks like flash is picky with path case while html5 could not care less :)

glad I found this tho, was starting to panic a little. think I will be sure to test in flash at least every other time now rather than once a week

thanks for the help muddy.


muddy_shoes(Posted 2012) [#8]
AS3 references files as embedded class members rather like a StringMap lookup so it is case-sensitive. In targets where files are actually read from the file system it will probably be OS-dependent whether they're case-sensitive.

All-in-all, don't use mixed case for your paths or filenames. It'll bite you at some point.


Paul - Taiphoz(Posted 2012) [#9]
yeah I wont from now on.