B4J Question app works in debug mode but not in release, why??

ilan

Expert
Licensed User
Longtime User
hi

i made a game in b4j, when i run it in debug mode everything works fine but in release i get an error

B4X:
B4J version: 3.61
Parsing code.    (0.01s)
Compiling code.    (0.04s)
Compiling layouts code.    (0.00s)
Compiling generated Java code.    Error
B4J line: 68
If c Is Pane Then
javac 1.8.0_51
src\b4j\example\main.java:506: error: incompatible types: Control cannot be converted to Pane
if (_c.getObjectOrNull() instanceof javafx.scene.layout.Pane) {
                      ^
1 error

you can download the project here: https://www.b4x.com/android/forum/threads/mad-maze-source-code.57835/#post-364001
 

jmon

Well-Known Member
Licensed User
Longtime User
you should replace "Control" by "Node" in the For Loop:
B4X:
For Each c As Node In mazepnl.GetAllViewsRecursive
    If c Is Pane Then
        Dim pnl As Pane
        pnl = c
        walls(wallsnr) = pnl
        wallsnr = wallsnr +1
    End If              
Next
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
actually i am doing it, but because i got that error i rewrite few times that code, i could not find "view" in b4j like i am used in b4a so i thought control is the right choice like in VB but jmon solved the problem, NODE is the answer... thanx @jmon and @Erel

it is still weird that it runs in debug :)
 
Last edited:
Upvote 0

jmon

Well-Known Member
Licensed User
Longtime User
Note that it is slightly better to write
@Erel, it would be nice if you could write a post about those small tips and tricks of B4J. I'm quite interested in knowing how to optimize my code for speed and lower memory consumption.

so would it even be better to write:
B4X:
For Each c As Node In mazepnl.GetAllViewsRecursive
    If c Is Pane Then
        'Dim pnl As Pane -->get rid of this
        'pnl = c -->get rid of this
        walls(wallsnr) = c 'input directly c here
        wallsnr = wallsnr +1
    End If            
Next

it is still a weird that it runs in debug
Yes, that's strange.
 
Upvote 0
Top