riaxe snippets
Posts tagged AIR
Pagination in Flex
Jun 9th
Recently while working on a flex project, had an issue while paginating a list of data. Could find many solutions for paginating of Datagrid and lists on the web but I needed little different. So created an application to paginate a large amount of data. This isn’t using any Datagrid or List but a simple VBox. I added some effects as well to it. I used a canvas having a list of images and at the bottom the paginator is placed with the “First”(<<), ”Previous”(<), “Next”(>) and “Last”(>>) buttons for navigation. One can click on the page number to navigate to any specified page.
We need 4 properties to set on application loading complete.
1. Set selectedIndex = 0 ; // As we need to show the first page on load complete.
2. Set visiblePages = the number of pages we want to show every time. Here the visiblePages = 3.
3. Set totalItems = the total number of items
4. Set itemsPerpage = the number of items to be shown in a page.
Screenshot given below.

You can click here to see the example.
I think this sample could be useful for all. Do post back for any issues or suggestions.
Thanks.
Adding namespaces in Actionscript3.0
Jan 26th
By defination – Namespaces give you control over the visibility of the properties and methods that you create. Think of the public, private, protected, and internal
access control specifiers as built-in namespaces. If these predefined access control specifiers do not suit your needs, you can create your own namespaces.
We can create our own namespaces in Actionscript 3.0.
Suppose we have a class named Employee having a method within named calculateSalary();
We can create our own namespaces to see the difference in incentives for RIA developers. We will create two namespaces as follows:
package com.xyzsystems.namespace {
public namespace codevils=http://riaxe.com/blog;
}
package com.xyzsystems.namespace {
public namespace others;
}
Lets create our Employee class where we will use these namespaces as follows:
package com.xyzsystems.employee
{
import com.xyzsystems.namespace.*;
public class Employee
{
others static function calculateIncentive():Number{
return 5000;
}
//
codevils static function calculateIncentive():Number{
return 7500;
}
}
}
We are done with the class. Lets test the calculateIncentive() method for different namespaces.
package com.xyzsystems.test
{
import com.xyzsystems.namespace.*;
import com.xyzsystems.employee;
import mx.controls.Alert;
use namespace others;
// use namespace codevils;
public class TestEmployee
{
public function TestEmployee():void {
var incentive:Number = Employee.calculateIncentive();
Alert.show("The incentive for the employee is :"+incentive);
}
}
}
The Alert will show this “The incentive for the employee is : 5000″;
We can also define the namespace like this -
var incentive:Number; incentive = Employee.codevils::calculateIncentive();
This would result in “The incentive for the employee is : 7500” in the Alert.

