progress bar tutorial

Warning:
This tutorial covers only Tiny Mobile Widgets versions.
On Mobile Widgets, use Loader, LoaderMini or ProgressBar prototype.

This chapter present the Tiny Mobile Widgets propress bar.
Tiny Mobile Widgets provide a progress bar component. Developer can display this progress bar into popup.

example

Note:
Progress bar require popup.
See popup tutorial to display and use popup.


Tiny Mobile Widgets progress bar is displayed via a Message on the "Board" channel.



Note:
Popup is required to display progress bar (see popup tutorial).


We create a popup to ask if user would quit widget.
We close popup after 5 seconds.
A progress bar displays the time left before closing popup.

Note:
We use a TimeSensor node.


Add TimeSensor node

Define TimeSensor node. TimeSensor interval is 5 secondes.


And declare TimeSensor node in script node.


Use TimeSensor to close the popup

Link TimeSensor node and hide popup function.


Modify hide popup function to use the time sensor

"cycleTime" event return a SFTime value.
Change hidePopup event type to SFTime.


Start TimeSensor

Launch TimeSensor when popup is opened.
To launch TimeSensor, we active the TimeSensor and we define the start time to current time.

Note:
current time is a "data_changed" function parameter


Create event to catch progression

TimeSensor return progression with fraction_changed event (return a SFFloat value).
In JavaScript, we add an event to catch fraction_changed.


Create function to process event

We would change progress bar when TimeSensor send fraction_changed event.

Note:
fraction_changed return a value between 0 and 1. Progress bar use value between 0 and 100.


Link fraction_changed event and moveProgressBar() function