pp Inventor 2
Programming mobile phones with Android
by App Inventor 2 - Juan Antonio Villalpando
- Initiation Tutorial App Inventor 2 -
Return to tutorial index
____________________________
Sensors
24.- Clock. Timer. Flashing colors on the screen.
ip24_clock
- We place one slider that this one ends between 1 and 2000.
_________________
Design
- Moving the Slider to set a new interval in the Clock (timer) so that it will act each that time.
- When acting the clock three random numbers from 1 to 255, are created corresponding to each of the basic colors.
- The sum of these colors is presented as Background color of the screen.
_________________
Blocks

_______________________________
25.- Clock. Traffic light.
ip25_semaphore
- We place one Canvas. Width: Fill parent, and Height: 400 pixel.
- Three balls (50, 10) (50, 90) (50.170). Radio: 40
- A Slider with values between MinValue 1 and MaxValue 200
_________________
Design

- Variable: Add
- Each time a occurs Interval Timer:
one unit is counted: add = add + 1
If add is> 16 then add back to 0 (new series)
If add is <= 6 then Red
If add is> 6 And add is <= 9 then Yellow
If add is> 9 then Color Green
_________________
Blocks

NOTE: This code is just one example of learning could be made more efficient.
Change orden color: First Red, then Green, then Yellow.
_______________________________
26.- Animated GIFs.
ip26_gif_animated
- Android does not get along with animated Gif, you have to use complex codes or tricks.
- In this case the trick that we use is to put an image in a directory Android and see that image with web browser.
When we got to project an image, it is saved in ...
/mnt/sdcard/AppInventor/assets/ninja.gif
so using the Internet browser get that picture on the screen.
file:///mnt/sdcard/AppInventor/assets/ninja.gif

_________________
Design

_________________
Blocks
_______________________________
26B.- Another way to animated GIFs.
- Another way to make animated GIF is carrying a series of "frames" that form the movement of the image and then presenting them to go through a timer (clock).
- In App Gallery we find this application inventor, who also participated in our contest in August 2015.
PHOTO_SURPRISE .aia
It is interesting to study the code and see how the effect of image motion occurs.
The objective of the application is to add a lively a photo immediately after being taken gif.
Imagination can place the gif in a room, in the hand of a child on a table ...

__________________________________
|