Friday, April 30, 2010

Flex Actionscript Goodness: A better for loop

Along with traiditional for loop for iterating, Actionscript also allows an easier way..
following example demostrates it

var arr:Array = ["mytest1", "mytest2", "mytest3"];
// Use a regular for in loop to access the properties in arr
for ( var i in arr ) {
trace( arr[i]);
}

Done!! Hurray!!

Friday, March 19, 2010

Convert Date to String in groovy

import java.text.SimpleDateFormat

long lTime = new Date().time

String formattedDate = getUTCDateString(lTime)
println formattedDate

def getUTCDateString(long lTime)
{
Date lDate = new Date(lTime)
def cal = new GregorianCalendar(TimeZone.getTimeZone('UTC'))
cal.set(lDate[Calendar.YEAR],lDate[Calendar.MONTH],lDate[Calendar.DATE],lDate[Calendar.HOUR_OF_DAY],lDate[Calendar.MINUTE],lDate[Calendar.SECOND])
String formattedDate = new SimpleDateFormat("yyyy-mm-dd hh:mm").format(cal.time);
return formattedDate
}

Tuesday, March 9, 2010

Check if String is Number

String nbrStr = "30239023902390239023902323"
boolean b = nbrStr.isNumber()
assert b == true

Groovy String to Integer

Converting a String to Number

String nbrStr = "100"
int i = nbrStr.toInteger()
assert i==100

Sunday, December 6, 2009

Converting String to Date in Groovy

Recently I was looking for a simple way to convert a String object to a Date format in groovy..
below is the example.

In groovy, its just a one liner to make this happen

String timeStampStr = "2009-12-01T12:36:22Z"
def strDate = new Date().parse("yyyy-MM-dd'T'HH:mm:ss'Z'",timeStampStr)
println strDate.


Sunday, November 1, 2009

Flex3 Animations


1. Easing Functions
Flex3 allows some cool effects using easing functions, you have to experience it.
Easing functions allows to give different effects to the components,
like a Bounce Effect
here is a good link of example based on that, thank you james for it

Good example to add the animations

Monday, September 14, 2009

Apache2.2 Proxy and Virtual Hosts

I created a Flex application using TWITTER Webservices, Since the CrossDomain policy of Twitter is very strong, My flex app was working on the development mode in flex builder but not outside.

Solution implement a Proxy.. Twitter API is a pure REST API , which uses GET as well as POST requests..
Following solution of Apache Proxy, works with the get request

ServerName mysite.com
ServerAlias tp.mysite.com
DocumentRoot "/var/www/"
AddHandler php5-script .php
AddType text/html .php

ProxyRequests off
Order Allow,Deny
Allow from all
ProxyPass /tproxy/ http://twitter.com/
ProxyPassReverse /tproxy/ http://twitter.com/
RequestHeader unset Accept-Encoding

#custom log file
LogLevel debug
ErrorLog /var/log/httpd/caw.local.error.log
CustomLog /var/log/httpd/caw.local.access.log combined