Trouble with which blocks to use to build a list of 3 items, then check it

46 views
Skip to first unread message

veronica stanley-hooper

unread,
May 4, 2017, 4:42:54 PM5/4/17
to MIT App Inventor Forum
I am developing an app for my elementary school students to learn their multiplication facts. I have an opening title screen and then I have two consecutive screens that walk the students through how to play the game. 

Here's my problem: On the 3rd screen, I have 3 numbers (I set the complete graphic with the three numbers as the screen background, then put three transparent .pngs in a table over the numbers on the background image in the correct position to overlay the numbers. I set the transparent images up as buttons.) I would like the buttons - 2 , 4, 8 - to play a sound "two", "four", "eight" when clicked. I would also like the screen to change upon the clicking of all three numbers.I have the buttons working with their respective sounds. I just cannot find the right blocks to code the rest.

Problem: Which blocks do I use for the programming to 'collect' the button clicks as the user clicks them, then 'know' when all three buttons have been clicked to automatically close this screen and open another?

PLEASE help. I am going out of my mind searching for this information.

Sincerely,
Veronica

SteveJG

unread,
May 4, 2017, 4:59:57 PM5/4/17
to MIT App Inventor Forum

You did not post an image of your blocks Veronica so here is the general advice you need:



and 


What you want to do can be done several ways.  You might set a Boolean value for each button (the second link blocks).  Set perhaps button1click to true in button1s event handler when button1 is clicked etc.
Then to know when the combination is correct, use a conditional constructions (the first link)  to find out when  button1click and  button2click and button3.click are true.  when you make your selection, change button1click to false and the others too to reset.

Show some blocks and you should get more specific advice.

Regards,
Steve




Italo

unread,
May 4, 2017, 5:04:20 PM5/4/17
to MIT App Inventor Forum
Well, there's a little problem you are going to have because you say you make components to overlay with graphics in the background. That may work in one screen but it will not work on screens with different sizes. You need to use relative positioning instead of absolute.
About your question, there's a lot of ways to do that, but I'm going to help you with an easy solution:

Create 3 global variables called Button1Clicked, Button2Clicked and Button3Clicked. Set them all to FALSE (the green false you find in the LOGIC drawer
Each time a button is touched, set the corresponding variable to TRUE (again, the green true), and ask IF Button1Clicked AND Button2Clicked AND Button3Clicked THEN open the new screen.

veronica stanley-hooper

unread,
May 5, 2017, 10:59:44 AM5/5/17
to MIT App Inventor Forum
Thank you for your specific advice. I am going to try your solution when I have a chance today after I teach school. Also, I understand your comment about the relative positioning. Exactly how would you set this up? I was considering slicing my image into segments and then fitting the segments into a table, but if there is an easier way that you can suggest I would love to hear your thoughts.

Thanks,
Veronica

Italo

unread,
May 5, 2017, 11:32:27 AM5/5/17
to MIT App Inventor Forum
Without knowing exactly how you want your screen layout, I can give a general advice, to use a plain background (gradient, texture, flat color, etc) and set buttons with images instead of text. 
And always use aligning (center, right, left) and percentages to size components, not pixels to ensure it looks right on every screen.
Will that work for your project? 
If not, show a screenshot of your layout and your blocks so we can have a better idea, like Steve said up there.

veronica stanley-hooper

unread,
May 5, 2017, 12:30:22 PM5/5/17
to MIT App Inventor Forum
I am a novice...forgive me. Which blocks do I use to say "Button1Clicked AND Button2Clicked AND Button3Clicked"? (The AND part is throwing me off.)

Thanks,
Veronica

Italo

unread,
May 5, 2017, 1:45:51 PM5/5/17
to MIT App Inventor Forum


veronica stanley-hooper

unread,
May 5, 2017, 3:04:58 PM5/5/17
to MIT App Inventor Forum
I attached a screenshot of what I have....does this look anything near correct? I cannot get my AI companion to connect on my PC right now. And for some reason when I try to download it is saying no new updates. Thank you in advance.
screenshot 2017-05-05_10h30_35.png

Italo

unread,
May 5, 2017, 3:57:04 PM5/5/17
to MIT App Inventor Forum
It should work. One thing you can optimize, is that you don't need to ask if [variable] = TRUE. Just do it like the example I sent you before. Only when using boolean values (true or false).
Or you can leave it as it is, doesn't matter really.

Abraham Getzler

unread,
May 5, 2017, 4:48:21 PM5/5/17
to MIT App Inventor Forum
I don't see the place in your button click events where you set the appropriate global variable to true.

You test it, but you never set it?

ABG

Abraham Getzler

unread,
May 5, 2017, 4:53:07 PM5/5/17
to MIT App Inventor Forum
By the way, the app would be more intuitive if each button click event did something to the appearance of that button
to show that it has already been clicked.

Consider changing the text to bold, or changing the background color or image of that button.

You could test the attribute you set in that AND tree instead of testing those three global variables,
killing two birds with one stone.

ABG

Italo

unread,
May 5, 2017, 6:10:08 PM5/5/17
to MIT App Inventor Forum
Oh, yes, Abraham. I didn't notice that. She did it in the first one but forgot the other two.
Also, I noticed now that you are asking if TwoButton, FourButton and FourButton are true.

It should be TwoButton, FourButton and EightButton.

veronica stanley-hooper

unread,
May 6, 2017, 12:07:39 PM5/6/17
to MIT App Inventor Forum
Thank you for pointing this out. I have revised this.

veronica stanley-hooper

unread,
May 6, 2017, 12:07:57 PM5/6/17
to MIT App Inventor Forum

veronica stanley-hooper

unread,
May 6, 2017, 12:09:36 PM5/6/17
to MIT App Inventor Forum
Yes, I agree. Once I figure out the programming issues, I plan to work on the appearance / user interface more closely so that it is appealing and user friendly for kids. Thank you for this suggestion.

veronica stanley-hooper

unread,
May 6, 2017, 12:15:56 PM5/6/17
to MIT App Inventor Forum
Thank you everyone! Your suggestions worked and I have learned a bunch. Now I need to work on my graphics. I appreciate your help VERY much!
Reply all
Reply to author
Forward
0 new messages