Creating an activity indicator

How to

Create an activity indicator to display when your application is busy performing a task.

Solution

Construct the activity indicator variable in the root of your class

var myActivity:ActivityIndicator = new ActivityIndicator();
//placing this at the class root allows other 
//application elements to reference it

Initialize your indicator's attributes

//set location
myActivity.x = 50;
myActivity.y = 50;
//set size
myActivity.width = 150;

//OPTIONAL: set animation speed between 0 and 1
myActivity.animationSpeed = 0.1;

//add to stage
this.addChild(myActivity);

//turn on animation
myActivity.animate(true);

Build Requirements

You must include the following class in your project:

import qnx.fuse.ui.progress.ActivityIndicator;

Discussion

When you create an activity indicator, you declare the ActivityIndicator variable and set its properties to whatever values your application requires. To display the indicator, add it to the stage with addChild(). The animation can be turned on and off anywhere the object is accessible by using the animate function, while the speed can be changed with the animationSpeed property.