For DynamicComponent extension, Shuffle block is not working properly and should not be used. We’ll attempt to address this issue and fix in next version.
Could this be related to the string type conversion that produces an error when I attempt to use the ListUtils Shuffle block on a list of sprites?
@Thomas_Leavitt for dynamic components extension, I believe there is a bug in the shuffle block. We’ll check in more detail and report back
FYI, I’m not using a dynamic component, this is a straight, manually defined list of sprites, being passed to another list through the ListUtils.Shuffle block. Just thought that details of a second reported problem with the Shuffle block might be helpful and prompt an insight.
Ah okay. ListUtils shuffling only works on strings. Can you post screenshot of your relevant blocks?
Why should Shuffle care what the data type of the list is?
I could revert back to the previously posted code (in another thread) where I basically created a look up table that let me manipulate a string based array that “stood in” for the sprite array (what I had set up before I realized I could actually put sprites in an array), but it would be so much cleaner to simply be able to shuffle the sprite list directly.
Shuffling cares because it has to compare each piece of data. Your sprites are complex objects. Place a sprite or like anything else like image in designer. Then go to blocks editor. Select that component to see it’s blocks. Scroll all the way down to see the component block; e.g. image1. Select it to place it in the blocks editor. Then use DoIt to see what it returns. That’s what that object representation is.
Dolt? Not familiar with that tool.
You’re comparing data when you Shuffle, not just randomizing the array index? Why? What function does doing that serve?
Make sure you ate connected to companion. Right mouse button on block and you’ll see the DoIt. It’s great for debugging.
Oops my bad I was thinking of sorting. We’ll do some testing by tomorrow
well, that’s the most important tool…
see also tip 4 here
Top 5 Tips: How to learn App Inventor
Thanks. I’d love to have that functionality working. Yes, I wouldn’t try sorting a list of Sprites based on the content of the image, although I suppose there might be some utility in sorting a list of sprites by name or other non-blob aspect…
Sorry, misread that as D o l t, not DoIt as one word, familiar with that from a previous posting that very useful link.
I was just loading the contents of variables into label text and using them as the equivalent of “print” statements, old school style, until I saw your link.
Shuffling of ANY component works good. See snapshot below. Notice that initially, list is CheckBox, Label and then Button. Next, I shuffle the list. The DoIt result is shown in the pop-up:
Better ways to manage large numbers of sprites than gigantic lookup tables?
As I posted in the Better ways to manage large numbers of sprites than gigantic lookup tables? thread:
it appears that using ListUtils to “Shuffle” a list of components converts that list into a list of strings? I’m getting a runtime error when I attempt to manipulate the list: “Property setter was expecting a com.google.appinventor.components.runtime.ImageSprite component but got a String instead.”
I haven’t had problems using this otherwise.