Friday, December 14, 2012

Variable

The variables provide the ways to keep and to modify the data and/or the states of the users/system. Using the variables will make the presentation of the content more dynamic, i.e., the content could be changed following the state/value of the variables.

There are two kinds of variable: System and User variables


System variable

It’s a set of predefined variable representing the proprieties of the mobile-phone where the application is running on, for instance, System screen size or Language, etc.You can see the liste of the system varibales on the variable dialog (Ctrl + Alt + v)

 

User variable

It’s a way to define, to keep and to modify the states of user's interactions. By now JM-Mobile provides two primitives variable types: STRING and INTEGER.

Modify the user variable

On an event occurred (begin, end, key pressed, etc.) author can choose to modify a user variable. With an INTEGER variable author can choose to set, subtract or plus a value to the variable; with an STRING variable author can choose to concat or replace a new string to the variable

Using variable

Using of variable make the presentation of application more dynamical. In general, to use a variable we put a $ at the beginning of the variable’s name (e.g. $myScore) and put it inside a pair of {}, e.g., {$myScore} 

Using variable in the text content

By example:
We have a variable called myScore that keeps a score of user. In the end of application we want to show this score, we can create a Text object and edit its text content as following: 
   “My score {$myScore}”

Using variable in the FileName attribute of an image object

This application of variable allows changing to corresponding image content with the situation of the user’s interaction.

By example:
We have a string variable called stateOfMind that can take a “happy”, “sad”, “lovesick”, etc. then we want to show an image corresponding with a state of user in the application, we can create an image object with its FileName attribute specified as following:

   “…/res/images/{$stateOfMind}.png”

No comments:

Post a Comment