[Script Info] Title: [Events] Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text Dialogue: 0,0:00:02.20,0:00:11.81,Default,,0000,0000,0000,,♩♫♪♬ Dialogue: 0,0:00:12.39,0:00:15.33,Default,,0000,0000,0000,,Hi and welcome back to App Inventor's Hour of Code. Dialogue: 0,0:00:15.34,0:00:17.40,Default,,0000,0000,0000,,- I am Emily.\N- And I am Shay. Dialogue: 0,0:00:17.55,0:00:22.23,Default,,0000,0000,0000,,In our last video we showed you how to make the Talk To Me app: You push a button and the phone talks to you. Dialogue: 0,0:00:22.75,0:00:25.59,Default,,0000,0000,0000,,- So cool. \N- Well, we had to start somewhere! Dialogue: 0,0:00:25.73,0:00:27.73,Default,,0000,0000,0000,,I am ready to get to the cool stuff. Dialogue: 0,0:00:27.75,0:00:33.74,Default,,0000,0000,0000,,Okay, now we are going to extend the Talk To me app so that it responds when we shake it and also so the user can input their own text. Dialogue: 0,0:00:36.20,0:00:37.50,Default,,0000,0000,0000,,>Stop shaking me!< Dialogue: 0,0:00:37.65,0:00:43.78,Default,,0000,0000,0000,,- Cool enough for you now?\N- I see endless opportunities. I can go on a run and get constant encouragement. Dialogue: 0,0:00:44.24,0:00:50.72,Default,,0000,0000,0000,,Great! So we are gonna get started and the great thing is, this takes only a couple of minutes because App Inventor makes it really easy. Dialogue: 0,0:00:50.86,0:00:56.19,Default,,0000,0000,0000,,Is your phone talking to you? Well, hang on, because it's about to get even more fun. Dialogue: 0,0:00:56.35,0:01:04.93,Default,,0000,0000,0000,,We left off with our Talk To Me app in the blocks editor. Right now we need to go back into the designer to add another component. Dialogue: 0,0:01:05.09,0:01:12.77,Default,,0000,0000,0000,,We want to extend Talk To Me so that the phone speaks when you shake it. To do that we need an accelerometer component. Dialogue: 0,0:01:12.97,0:01:23.54,Default,,0000,0000,0000,,Click on the sensors drawer and drag out an accelerometer sensor. This is another non-visible component - so it drops down to the bottom of the screen. Dialogue: 0,0:01:25.51,0:01:28.55,Default,,0000,0000,0000,,That's all we need for right now! Go back over to the blocks editor. Dialogue: 0,0:01:28.68,0:01:34.43,Default,,0000,0000,0000,,As you develop your apps you will move back and forth between the designer and the blocks editor quite a bit. Dialogue: 0,0:01:35.72,0:01:41.04,Default,,0000,0000,0000,,We now need a block for when the phone is shaking. This is also called an event handler. Dialogue: 0,0:01:41.21,0:01:45.81,Default,,0000,0000,0000,,Drag out the "when AcceleromenterSensor1.Shaking" block. Dialogue: 0,0:01:45.99,0:01:49.91,Default,,0000,0000,0000,,So, when this event is triggered that's when the phone is being shaken. Dialogue: 0,0:01:50.11,0:01:54.26,Default,,0000,0000,0000,,What do we want to happen then? We want the phone to talk to us, right? Dialogue: 0,0:01:54.37,0:02:00.52,Default,,0000,0000,0000,,So, we already know the blocks that handle that - the same blocks that we have inside the "Button1.Click" event. Dialogue: 0,0:02:01.16,0:02:07.06,Default,,0000,0000,0000,,Here is a cool shortcut that will help you program in App Inventor even more quickly. You can copy and paste blocks. Dialogue: 0,0:02:07.26,0:02:14.86,Default,,0000,0000,0000,,Click on the purple TextToSpeech block. Hit the key combination your computer for copy just like you would do with text. Dialogue: 0,0:02:15.04,0:02:21.64,Default,,0000,0000,0000,,And then hit the key combination for paste. Voilà, you have a new set of the TextToSpeech and text blocks. Dialogue: 0,0:02:21.79,0:02:26.24,Default,,0000,0000,0000,,Drag this new set down into the accelerometer shaking event block. Dialogue: 0,0:02:26.40,0:02:33.09,Default,,0000,0000,0000,,If you had any trouble copying and pasting blocks, that's okay. You can also drag out new blocks from the drawers on the left. Dialogue: 0,0:02:33.28,0:02:41.67,Default,,0000,0000,0000,,Remember, we got the TextToSpeech.Speak block from TextToSpeech and we got the plain text block from the built-in text drawer. Dialogue: 0,0:02:42.78,0:02:49.40,Default,,0000,0000,0000,,So, right now, the phone will speak out loud if you shake it. But wouldn't it be much more fun if the phone says something about been shaken? Dialogue: 0,0:02:49.56,0:02:54.57,Default,,0000,0000,0000,,Let's put in a funny phrase. I am going to type in "Stop Shaking Me!". Dialogue: 0,0:02:56.47,0:02:59.31,Default,,0000,0000,0000,,Okay, try it out! Pick up your phone and shake it. Dialogue: 0,0:02:59.56,0:03:00.92,Default,,0000,0000,0000,,>Stop Shaking Me!< Dialogue: 0,0:03:01.07,0:03:11.36,Default,,0000,0000,0000,,So, our app is pretty cool, right? But wait! There is one more thing to add. Imagine sharing this app with your friends: Don't you think it would be a lot more fun if they can tell the phone what to say? Dialogue: 0,0:03:11.56,0:03:19.27,Default,,0000,0000,0000,,To set this up go back into the designer, go to the user interface drawer and pull out a text box. Dialogue: 0,0:03:21.93,0:03:25.18,Default,,0000,0000,0000,,Let's rearrange that a bit and put the button under the text box. Dialogue: 0,0:03:26.49,0:03:27.30,Default,,0000,0000,0000,,Okay, guess what... Dialogue: 0,0:03:27.68,0:03:28.64,Default,,0000,0000,0000,,Back to the blocks. Dialogue: 0,0:03:28.78,0:03:36.13,Default,,0000,0000,0000,,Click on TextBox1 and look at the blocks it has. We now want to change what happens when the button is clicked. Dialogue: 0,0:03:36.33,0:03:42.29,Default,,0000,0000,0000,,Instead of saying a fixed phrase we want the app to say whatever the user has typed into the text box. Dialogue: 0,0:03:42.49,0:03:51.83,Default,,0000,0000,0000,,Scroll all the way down to the green blocks that we call "getters" and "setters" because they allow you to get and set the properties of the component. Dialogue: 0,0:03:51.95,0:03:58.72,Default,,0000,0000,0000,,You want to get the text that has been typed into the box. So you need the getter block for "TextBox1.Text". Dialogue: 0,0:03:58.86,0:04:02.63,Default,,0000,0000,0000,,Put that block inside the "when Button1.Click" block. Dialogue: 0,0:04:02.78,0:04:11.71,Default,,0000,0000,0000,,To do this you have to throw away the old text block and then click this new TextBox1.Text block in its place. Dialogue: 0,0:04:11.86,0:04:20.29,Default,,0000,0000,0000,,Try your app out again. When you click in the blank text box on your phone your keyboard will come up and you can type in whatever you want. Dialogue: 0,0:04:20.42,0:04:23.66,Default,,0000,0000,0000,,Then, click "Talk To Me" and see what happens. Dialogue: 0,0:04:23.86,0:04:24.98,Default,,0000,0000,0000,,>Hello World< Dialogue: 0,0:04:25.15,0:04:31.92,Default,,0000,0000,0000,,There are some cool ways to extend this app. See the written tutorial for some great ideas for making it even better. Dialogue: 0,0:04:32.08,0:04:37.08,Default,,0000,0000,0000,,If you had any trouble with this tutorial you can view the written version on our website. Dialogue: 0,0:04:38.73,0:04:41.26,Default,,0000,0000,0000,,>Stop! Stop! Stop! Stop!<\N- Aw man, we made a real app! Dialogue: 0,0:04:41.40,0:04:44.30,Default,,0000,0000,0000,,>Stop! Stop! Stop! Stop!<\N- That's kind of annoying! Dialogue: 0,0:04:44.40,0:04:45.59,Default,,0000,0000,0000,,>Stop! Stop! Stop! Stop!<\N- You made it! Dialogue: 0,0:04:45.72,0:04:46.96,Default,,0000,0000,0000,,Oh right. Dialogue: 0,0:04:47.09,0:04:52.93,Default,,0000,0000,0000,,Well you are gonna have a ball with our next step because we're gonna show you how to make a ball roll around the screen when you fling it with your finger. Dialogue: 0,0:04:53.10,0:04:55.66,Default,,0000,0000,0000,,>Stop! Stop! Stop! Stop!<\N- Can't wait! Dialogue: 0,0:04:55.83,0:04:57.80,Default,,0000,0000,0000,,>Stop! Stop! Stop! Stop! Stop! Stop! Stop Shaking Me!< Dialogue: 0,0:04:58.07,0:05:07.13,Default,,0000,0000,0000,,♩♫♪♬