Main menu

Monthly Archives: April 2014

Post navigation

This week we will build an app has three buttons to launch our favourite websites.

The app will consist of three buttons across the top. The buttons will launch the Google website, the YouTube website and our own Athenry CoderDojo website.

We will also change the icon of the app from the default one supplied by App Inventor.

Getting started

Begin by dragging and dropping a HorizontalArrangement control from the Palette onto the screen. Rename this control to hsaButtons

Drag three buttons from the Palette and drop them onto the HorizontalArrangement control. Rename the buttons to btnGoogle, btnYouTube, btnCoderDojo. When dropping the buttons onto the HorizontalArrangement, try to ensure the buttons are overlapping. This will make sure they appear side by side.

Drag and drop a WebViewer control from the Palette onto the screen. Rename this control to wbvBrowser.

Creating the scripts

Click the Blocks button.

Select the btnGoogle Block.

Select the “when btnGoogle.Click do” script.

Select the wbvBrowser Block

Select the “call wbvBrowser.GoToUrl” script

Drag the “call wbvBrowser.GoToUrl” script and drop it into the “when btnGoogle.Click do” script.

Drag a blank Text block and drop it at the end of the “call wbvBrowser.GoToUrl” script.

Full steps are included in the following link

Recently, Eugene McDonough from the Hello World Foundation travelled to Nigeria to help start up a CoderDojo. To introduce groups to Scratch, he used none other than Martha Fahy’s Scratch Beginners notes from here in Athenry, beginning with the Jaws game that our Athenry ninjas will recognise very well!

Oliver Thompson, our lead mentor for the Scratch Advanced group in CoderDojo Athenry, recently did a live linkup to a new CoderDojo in Tanzania. Oliver’s notes on the experience are below.

Eugene from the Hello World Foundation (www.helloworldfoundation.com) originally contacted Michael from Coder Dojo Athenry (https://cdathenry.wordpress.com) with the fantastic idea of doing a Live Link up with CoderDojo Athenry, CoderDojo Limierick and new CoderDojos in Tanzania and Nigeria. Eugene would be traveling to Africa to help set up new CoderDojos.

Many emails and phone calls later we had a tentative arrangement to Link up on Saturday the 8th of March, with a dry run scheduled for the Wednesday the 5th of March at the School.

Ciaran of Gairmscoil Mhuire VEC Athenry kindly gave permission to use the school during school time for this dry run, many thanks to the school for this.

Anyway, a few more emails back and forth between Athenry and Tanzania, events began to conspire against us. Internet access was not going to be good enough, if it existed at all.

It was at this point that we hit upon Plan B, I would get into work early on Tuesday 4th of March and we would try the connection from there. I duly arrived at around 6:00 am and got everything set up. And nothing happened! I sent a few emails, wondering where people were, no response, so packed up all my equipment and went back to work. And then Eugene came back on line, we were on for the trial run.

Packed up my equipment again and back to training room.

I Connected the laptop to the overhead projector, started up the Scratch Presentation.

Next was the tablet for the Skype session. I had brought my tripod in as well and in the best frontier tradition tied the tablet to the tripod with a bit of elastic. But hey, it worked a treat.

The tablet was set up in front of the big screen on the wall that had the Scratch Presentation on, so for the people at the other end it just looked like they were at a lecture, with me in front of the slides.

At the other end we had George and Godfrey who are the chief mentors for the new CoderDojos being set up, as well as one or two other people.

The Presentation went really well, Skype worked a treat, George and Godfrey could see all the slides and any Scratch code that I was showing them, it was just like being present at a lecture. Sound was no problem, even from a small tablet.

We spent about an hour on Skype, going through the Presentation and also demonstrating the code through Scratch as well.

It was looking good for the Main Event on Saturday 8th at this stage and I was figuring out if there was any better ways of presenting, and also if I could find anything better that a bit of elastic to hold the tablet to the tripod.

Unfortunately though, we could not go ahead on the Saturday as the location that was being used in Tanzania for the CoderDojo Session did not have a good internet connection.

The trial run and he Skype session were definitely worth doing, at the very least it proved that with a little bit of ingenuity (and elastic) that with fairly simple technology, a laptop, projector and tablet and the wonders of the Internet and Skype it is possible to run training sessions anywhere in the World.

Getting Started

To create this app you need to drag and drop a two label components on to the screen. The first label is called lblTitle; this component fills the width of the screen. This label will be the Title displayed. The second label lblTimer also fills the width of the screen and is the countdown text in the app.

You also need to drag and drop a Clock component onto the screen. This component is not visible and will appear under the screen, all the default settings for this component are ok

Initializing Global variables

Click on the Blocks button to open the script editor. In the script editor a number of global variables must be created and initialized. The first variable is MillisecondsToChristmas, the initial value for this variable is zero. The other Global Variables are listed below and they are all set to zero.

DaysLeft

HoursLeft

MinutesLeft

SecondsLeft

MillisecondsForNow

When app starts calculate number of milliseconds to Christmas

When the app starts we use the Clock component to calculate the number of milliseconds to Christmas, this is stored in the Global variable MillisecondsToChristmas. Please note that the number of milliseconds calculated is not from the current time to Christmas but rather from Jan 01 1970. We will calculate the number of milliseconds for the current time later. Once we have this value we will subtract it from the number of milliseconds to Christmas.

Using the Clock Timer event to count down

The Clock component has a “Timer” event that fires every second. In this event we will calculate the number of milliseconds for the current time. This is stored in the Global variable MillisecondsForNow. The number of milliseconds for the current time is subtracted from the number of milliseconds to Christmas to give the number of milliseconds between now and Christmas. This is converted to seconds and stored in a local variable NumberOfSeconds. A number of local variables are needed

SecondsInMinute = 60

SecondsInHour = 3600

SecondsInDay = 86400

MinutesInHour = 60

HoursInDay = 24

Using the Clock Timer event to count down

In order to calculate the number of days, hours, minutes and seconds left to Christmas we use a couple of Math scripts

Modulo – returns the remainder of a division

Floor – returns the greatest integer that’s less than or equal to the given number.

The script to calculate the Days, Hours, Minutes and Seconds is displayed below.

As discussed at this week’s session, we will be awarding belts on Saturday 12 April. In advance of that, Modders should work on developing as good a mod as possible, in either Java or JavaScript. I can help you publish your mod to the CoderDojo Athenry website, so get in touch with me (Michael) by email if you have questions.

Overview

Here is all of the code for our mods to define our first item, first block, and first recipe. In addition to 3 Java files, there is 1 language resource file (en_US.lang) and also 2 PNG files that are not included below: one for the block texture and one for the item texture.

Refer to the image below and to earlier posts in this series to see how these files should be arranged in a package.