July 19, 2007

Before I leave for my trip, I thought I’d post another tip in my series of tips for Flex beginners

varargs in AS3

Did you know that just like the varargs functionality in Java you could define an ActionScript function so that it takes a variable number of arguments?

You can do this using two approaches: arguments object or … (rest) parameter I am giving a brief example of the … (rest) parameter approach here, you can read in detail about both approaches in this article on Livedocs

// Here's a bare bone example:

            private function average(... args):Number{
               var sum:Number = 0;
               for(var i:int = 0; i<args.length;i++){
                       sum += args[i];
               }
               return sum/args.length;
            }

// Now all the below calls would work

               var a:Number = average(100,200);
               a = average(100,200,300);
               a = average(100,200,300,400);
               a = average(100,200,300,400,500);

read more

July 19, 2007

Starting tomorrow early morning, I will be traveling for a month to meet the various people that I work with at SAP in Germany and United States. My travel plan looks like this:

  • Heidelberg, Germany (20th July to 28th July)
  • Washington DC, USA (28th July to 5th August)
  • Newtown Square, PA, USA (5th August to 19th August)
  • Washington DC, USA (19th August to 21st August)
  • Bangalore, India (22nd August)

I am very excited about the trip and the two reasons contributing most to this excitement are:

  • This is my first visit to anywhere in Europe (barring a few transit stops at Heathrow Airport) and I am really looking forward to some relax time in the beautiful European weather… I’d appreciate your suggestions on places I should visit in and around Heidelburg.
  • Also, I will be able to catch the onAir bus in Washington DC on the 20th of August, which is real cool as i would get to meet all these people whose blogs I read so religiously every morning.

If you live in any of the above cities and you like talking about Flex, drop me a line and we’ll catch for coffee or something.
read more

July 9, 2007

Continuing my series of Flex tips for beginners ….

-keep-generated-actionscript

When you compile an mxml application, all your mxml is first converted to actionscript and then this actionscript is further compiled into a SWF. You can see this generated actionscript to learn the flex framework in depth using the flex compiler flag -keep-generated-actionscript.

To set this flag in Flex Builder right click to open the project Properties, select Flex Compiler, and add -keep-generated-actionscript to the Additional compiler arguments …. now rebuild the project and you will see a new folder called ‘generated’ that appears and has all the generated code.

You could also use just the short form -keep in place of the long -keep-generated-actionscript. read more

July 7, 2007

Continuing my series of tips for Flex beginners ….

filterFunction for real time filtering of data

A filterFunction allows you to create a filtered view of an ArrayCollection or XMLListCollection based on some criteria. This is useful in showing only relevant part of the data to the user ….. AutoComplete functionality or Google Suggest like functionality can be implemented using filterFunctions.

Below is an example of filterFunction in action:

read more

July 6, 2007

I have been doing this Flex Tip of the day series on flex-india and people have told me that these tips could be helpful to people outside the list as well so i will re-post the tips I have written about till now here on Rags to Riches over the next few days and then whenever I post a new tip I will post it on both mediums. Most people on the Flex-India list have a beginner – intermediate level expertise in Flex and these tips are focused at that target audience.

So lets start with a very basic yet useful tip ….

mx free mxml

How many times do you type ‘mx’ when writing an mxml application, i
type it zero times .. Here’s how …

<?xml version="1.0" encoding="utf-8"?>
<Application xmlns="http://www.adobe.com/2006/mxml">

/*now you can use the tags without mx: and
code hinting in FlexBuilder still works */

   <Canvas>
      <Button/>
   </Canvas>

</Application>

read more