Tuesday, October 6, 2009

How to set basic authentication for php in flex 4

I have listed down the steps which will help you to use basic authentication for php services using Zend in FlashBuilder4

1. Have a function called initAcl($acl) in the php service similar to the one given below. All the functions inside the service which need authentication should be mentioned in this function( i.e., initAcl)

function initAcl(Zend_Acl $acl) {
$acl->allow('role1', null, 'function1');
$acl->allow('role2', null, array('function1', 'function2'));
return true;

Please find a sample service here

2. Have a security.xml file which specifies the user roles and has user name and passwords stored in it. Sample contents of the xml file is given below.

<role id='admin'>
<user name='user1' password='pwd'/>
<role id='hr'>
<user name='user2' password='pwd2'/>

3. Security.xml file can be placed anywhere (placing it outside the webroot is recommended. ) The path has to be specified in the gateway.php file . Also a small code has to be added in the gateway.php file as given below.

$auth = new Zend_Amf_Adobe_Auth("C:\wamp\security.xml");

Refer to this gateway.php file to know where exactly should the above code be added

4. below code has to be added in the mxml, where serviceName1 is the name of the service created.

Support for basic authentication in php is added in Beta 2 release of FlashBuilder 4.

Thursday, September 10, 2009

Whats new in charts in Flex 4

I have already discussed about few of the enchancements done in Charts for Flex4, in my earlier posts. Direct links to those posts can be found below.

Apart from the above two enhancements, support is also provided for custom filter functions on the chart series. 2 new properties filterDataValues and filterFunction have been added to series.

3. filterDataValues: If filterFuction is set, filterDataValues and filterData are ignored. If filterDataValues property is set to none, series will not filter its data before displaying. If filterDataValues is set to nulls, series filters data like null, undefined, or NaN before displaying. If this property is set to outsideRange, series filters its data like null, undefined, or NaN and also the values that are outside the range of the chart axes. If you know that all of the data in the series is valid, you can set this to none to improve performance.

4. filterFunction: Specifies a method that returns the array of chart items in the series, that are to be displayed. If this property is set, the return value of the custom filter function takes precedence over the filterDataValues andfilterData properties. But if it returns null, then filterDataValues and filterData will be prefered in that order.

The custom filterFunction has the following signature:

     function_name (cache:Array):Array { ... }
Below is an example of custom filter function:

public function myFilterFunction(cache:Array):Array {
var filteredCache:Array=[];
var n:int = cache.length;
for(var i:int = 0; i < n; i++){
var item:ColumnSeriesItem = ColumnSeriesItem(cache[i]);
if(item.yNumber > 0 && item.yNumber < 700)
return filteredCache;

5. If you are working with Data Centric applications, binding data to charts has been made very simple in Flash Builder 4. I am going to talk about this in my future posts. Watch out this space for more on DataCentricDevelopment support for Charts.

6. Apart from the enhancements mentioned above, there have been a lot of bug fixes. Please use this link to log\ serach for bugs.


Tuesday, September 8, 2009

Reading from the web "Readefined"

U are reading a really long blog and are lazy to scroll till you reach the end of the page. Imagine how cool it would be if you can read the same blog in a multi-column layout, just as if you were reading a paper!
Here is a cool app which helps you do just the same which is developed by one of our collegues, Anirudh. It uses TLF(Text layout format) included in Flex 4. Now this is what i call awesomeness reAdefined.

Sunday, June 21, 2009

Inverted axis supported in Flex 4 charts

We can now create charts with inverted axis. A column Chart with inverted axis will look like this.

This is made possible by adding a new property "direction" on NumericAxis from which the LinearAxis, LogAxis and DateTimeAxis are derived. Accepted values for "direction" are normal and inverted. If the value is inverted for its "direction" property, axis will be inverted. The default value for direction is normal.
Here is a sample and source for the same.

New style renderDirection for PieSeries added in Flex 4

A new style renderDirection is added to PieSeries depending on which the wedges in the series are drawn. It accepts 2 values "clockwise" and "counterClockwise".
Default is counterClockwise which shows current behavior, renders the wedges in anti-clockwise direction. clockwise renders them in clockwise direction.

Click here to check out a working example
Click here for the source