Property getter was expecting a com.google.appinventor.components.runtime.ImageSprite component but got a Boolean instead


HI i have an error with my code that i need help with
after i turn on my app and chose a leve(1-3) and press reset TWICE (doesnt matter on which level i am) the error is shown heres a file as well:
mole_checkpoint1.aia (3.0 MB)
any help i appreciated

How can you press Reset (button) twice? On the first press you should be opening Screen1, and therefore the Reset button will not be available ?

  1. You do not appear to stop the clock
  2. You are not switching screens correctly
2 Likes

reset

1 Like

Hello Nikola

There are Procedures that have identical names to the Sprite they move - that shouldn't be. Just prefix each with 'procedure' for example; procedure_TENSE. Since you also have procedures of the same name across Screens, I would make them unique. For example: procedure_TENSE_scrn2, procedure_TENSE_scrn3, procedure_TENSE_scrn4

In general your component naming is poor, making your code difficult to follow. Never remove the component type from it's name. For example 'bod' could be Label_bod, 'stolci' could be List_stolci_scrn2.

All that said, I cannot find the root of the runtime error. :thinking:

Note ABG's correction of your reset procedures - currently your App opens several instances of Screen1 which will eventually crash the App. 'close screen' will take the User back to the original Screen1 (the screen that launched the current screen) automatically.

1 Like

I couldn't find an error but... The only possibility is related to the sprites' list, nowhere else is a component call. I think the problem lies in that calling a new screen the timer is already firing before the sprite list is initialized. In that moment the "random pick item" could call a sprite of the list that has not been listed so far. The error always comes when pressing a button for a next level. I have changed the code by implementing an initializing procedure to all screens that starts the timer; stopping the timer when reset. The clocks in all screens are set to a waiting status (Timer always fires "off"). This way the error didn't arise (to my experience); or implement a timer that delays each screen for a short instant while being started, so giving enough time to complete the sprites list.

mole_checkpoint1 (2).aia (3.0 MB)

4 Likes

so the process goes like this: turn on the app->choose a level 1-3->press reset->main menu->choose a level 1-3->press reset->main menu->choose a level 1-3 ->error message pops up but the game works normally

Ty so much

Thank youu

So in fact TimAI2 was the first to notice the Clock Timers were not handled correctly.

For anyone that finds their way to this Topic looking for clues to solve their own App's problem:

[1] Tip: Always use meaningful, unique names for components and never remove the component's type name. For example:

Label_Error_Messages

From this name we know the component is a Label and that it is intended to display error messages.

[2] Tip: It is best to set the attributes of Clock Timers in the Blocks where you can see their settings and modify as required, without having to go back into the Designer:

InitTimerInBlocks

[3] "Timer Always Fires" should normally be set to false. It is only used for Apps that need a timer to continue to run even if the App is not shown on screen - a very rare requirement.

[4] If you want a Timer to only have one elapsed time event when triggered, you can set it like this:

TimerFiresOnce

[5] If your App is taking the User to a different screen, ensure that all timers on the current screen are off (not running):

AllTimersOff

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.