Property getter was expecting a ImageSprite component but got a String instead

35 views
Skip to first unread message

Jayne Vidheecharoen

unread,
Aug 9, 2015, 11:00:13 PM8/9/15
to MIT App Inventor Forum
I'm trying to use the TinyDB to pass information about an ImageSprite from one screen to another. I have been able to do this successfully before in the same app so I'm confused why it's not working here. This is what I'm trying to do (also attached a diagram incase it makes more sense):

From Screen1, tapping a photo thumbnail opens up Detail Screen. 
On Detail Screen, you will see the photo with an ImageSprite (Highlight1) on it. 
I would like to store the information about this image sprite in the TinyDB.
When I go back to Screen1 and tap Demo, I'd like to see the photo with an Link1 ImageSprite that has the parameters as the one on the detail screen. 
Eventually I'd like to pass things like the width, height, location so it appears in the same as the one on Detail Screen. 
Right now I'm just trying to pass the image sprite's picture to start. 

But when I go to Demo screen I get the error "Property getter was expecting a ImageSprite component but got a String instead." 
I understand this means it's looking for an ImageSprite and getting a String, but I don't understand why it's getting a string when I've stored the Highlight1 ImageSprite as the value for my Hotspot1 key. I even set the key to a dummy sprite on Screen1 so it should start with a sprite.


See screenshots for more info. Can also attach the .aia if it's easier.

(I am testing by downloading the actual .apk because I need the camera and multiple screens)

Screen Shot 2015-08-09 at 7.36.05 PM.png
Screen Shot 2015-08-09 at 7.54.43 PM.png
Screen Shot 2015-08-09 at 7.54.50 PM.png
Screen Shot 2015-08-09 at 7.54.59 PM.png

Jayne Vidheecharoen

unread,
Aug 10, 2015, 2:06:37 AM8/10/15
to MIT App Inventor Forum
Nevermind! I think I figured out what was going on. Maybe two things. One, possibly because I was trying to store the whole component rather than a property of the component? Maybe? And then two, in my PlayDemo.Initialize it wasn't finding the ImageSprite Picture it was looking for so it was defaulting to the string "none" and coming back with a string in my error. 

Ended up skipping the picture part anyways and sending over the width/height/location to replicate it, which works for me. There must be an easier way to do this, though right? It seems I should be able to like make a hotspot object and just load an instance of it, instead of having to recreate it from the parameters individually each time. Is it only possible to store the properties of a component and not the component itself? I am going to have a lot of these (at least 18) so it will be tedious having to load each one like this... I'm guessing I need to make some sort of loop to load all of them up.


Taifun

unread,
Aug 10, 2015, 9:21:16 AM8/10/15
to MIT App Inventor Forum
 Is it only possible to store the properties of a component and not the component itself?
you can't store a component in TinyDB
but you could store the index of your BGImageSpriteList in TinyDB instead
Taifun
Reply all
Reply to author
Forward
0 new messages