Upload
griselda-jordan
View
223
Download
0
Embed Size (px)
DESCRIPTION
wall o The wall represents the screen o New item on top “a la facebook” set reversed (true) - to reverse order o Clear the wall wall->clear o Background color and picture wall->set background(colors->random) o Title and subtitle wall->set title(“Title of my change”)
Citation preview
apps
Find the latest version of this document at http://touchdevelop.com/slides .
learning objectiveso writing apps!
o Wall, Tap events and Pageso Recordso Geo-locationo Searcho Web APIs and web requests
• RSS, JSON, XML
wallo The wall represents the screeno New item on top “a la facebook”
set reversed (true) - to reverse ordero Clear the wall
wall->clearo Background color and picture wall->set background(colors->random)
o Title and subtitle wall->set title(“Title of my change”)
Wall – input, output
o Ask the user number• var x := wall -> ask number (“Enter the
number”)o Display the content
• (“ current sum up to “ || n || “is” || sum) -> post to wall
inputo user may be asked for text, Boolean, numbers
var name := all→ask string(“Enter your name”)var age := all→ask number(“Enter your age”)var ok := all→ask boolean(“Are you ok?”)☁ http://touchdevelop.com/vxez
o user may pick a time, datevar date := all→pick date(“Enter your birthdate”)☁ http://touchdevelop.com/ryor
textboxo A skin-able textbox
var tb := wall->create text box(“Run”, 19)
o Change color, font size, etc…o Attach tap event event tap wall TextBox(item : TextBox) if item->text->equals(“Run”) then ...
page stacko A page contains a “wall”o Pages can be stacked
• wall->push new page, adds a new blank wall
• wall->pop page, removes the top wallo The user can pop a page by pressing
the back button
recordso structured data
• Table: Similar to your Excel table.• Index: table with index lookup• Object: garbage collected objects (and
collections)• Decorator: add fields to existing objects
record car model : string year : number
o tablevar r := car table->create rowr->model->set(“beetle”)var year := r->year->get
o index (model is key)var r := car table->at(“beetle”)r->year->set(“beetle”)
o objectvar r := car table->creater->model->set(“beetle”)r->year->set(1970)var rs := car table->create collectionrs->add(r)
1 table per script
Keys are immutable
Collection is like a list
geo-locationRetrieve the longitude and latitude of the phone.o var loc := senses->current location
• Low precision 1 mile.• Might use WiFi or Cell tower
o var loc := senses->current location accurate• Better precision, tries to force GPS.
o Easy way to show a maploc->post to wall
invalid valueso What if the user refuses to give his
location?var loc := senses->current location
o The value loc is invalid.if loc->is invalid then // do something without location
searcho Built-in Bing searchweb->searchweb->search imageso Built-in Twitter/Facebook searchsocial->search
web requestso “if you need something, there is probably
a Web API that does it”o Full support for HTTP requests// setup requestvar request := web->create request(url)// send request, receive responsevar response := request->send// read responseresponse->content->post to wall