110 likes | 281 Views
apps. l earning objectives. writing apps! Wall, Tap events and Pages Records Geo-location Search Web APIs and web requests RSS, JSON, XML. wall. The wall represents the screen New item on top “a la facebook ” ( set reversed to reverse order) Clear the wall wall->clear
E N D
learning objectives • writing apps! • Wall, Tap events and Pages • Records • Geo-location • Search • Web APIs and web requests • RSS, JSON, XML
wall • The wall represents the screen • New item on top “a la facebook” (set reversed to reverse order) • Clear the wall wall->clear • Background color and picture wall->set background(colors->random) • Title and subtitle wall->set title(“Title of my change”)
textbox • A skin-able textbox vartb:= wall->create text box(“Run”, 19) • Change color, font size, etc… • Attach tap event event tap wall TextBox(item : TextBox) if item->text->equals(“Run”) then ...
page stack • A page contains a “wall” • Pages can be stacked • wall->push new page, adds a new blank wall • wall->pop page, removes the top wall • The user can pop a page by pressing the back button
records • 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
1 table per script record car model : string year : number • table var r := car table->create row r->model->set(“beetle”)var year := r->year->get • index (model is key) var r := car table->at(“beetle”) r->year->set(“beetle”) • object var r := car table->create r->model->set(“beetle”)r->year->set(1970)varrs:= car table->create collectionrs->add(r) Keys are immutable Collection is like a list
geo-location Retrieve the longitude and latitude of the phone. • varloc := senses->current location • Low precision 1 mile. • Might use WiFi or Cell tower • varloc := senses->current location accurate • Better precision, tries to force GPS. • Easy way to show a map loc->post to wall
invalid values • What if the user refuses to give his location? varloc := senses->current location • The value loc is invalid. if loc->is invalid then // do something without location
search • Built-in Bing search web->searchweb->search images • Built-in Twitter/Facebook search social->search
web requests • “if you need something, there is probably a Web API that does it” • Full support for HTTP requests // setup requestvar request := web->create request(url)// send request, receive responsevar response := request->send// read response response->content->post to wall