Tour de Flex

February 4, 2009 at 11:35 am (Flex) ()

Tour de Flex is awesome!

Permalink Leave a Comment

Validating real/integer numbers in Flex

December 19, 2008 at 4:05 pm (Flex) (, , , )

Written for: Flex

Below is a short code to determine whether a number is real (floating). To find if a number is an integer, change the domain property in NumberValidator tag from “real” to “int”.


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

    <mx:Script>
        <![CDATA[
            import mx.controls.Alert;
        ]]>
    </mx:Script>

    <mx:TextInput id="myTxtInput"/> 

    <mx:NumberValidator id="myNumberValidator"
        domain="real"
        source="{myTxtInput}"
        property="text"
        trigger="{myTxtInput}"
        triggerEvent="focusOut"
        valid="Alert.show('real number')"
        invalid="Alert.show('hmmm....unreal number?')"/>

</mx:Application>

Permalink Leave a Comment

AS3.0: Add one or more elements to the begining of an array

November 7, 2008 at 5:00 pm (ActionScript) (, )

Written for: ActionScript 3.0

To add one or more elements to the begining of an array, you will have to use unshift method of Array class.

Below is an example.

var albums:Array = new Array("Natty Dread","Rastaman Vibration","Exodus","Kaya");
albums.unshift("Catch A Fire");

trace(albums); //Catch A Fire,Natty Dread,Rastaman Vibration,Exodus,Kaya

Permalink Leave a Comment

Bombay – (Rickshaw or Taxi) = Beautiful Bombay

October 16, 2008 at 12:32 pm (Bombay) ()

I had the most pleasant ride to work today. The reason being – there were absolutely no god damn rickshaws or taxis on the streets of Bombay.  The reason for that being – they had a stupid strike (The hardship of which will never be known).

To see Bombay, devoid of rickshaws or taxis is unimaginable. But, the “emptiness” on the streets is so beautiful. I could never picture a ride  without cussing the rickshaw and taxi fellas. (I cuss at other vechiles too)

I hope someone figures out a way to keep this “emptiness”. (Focusing and improving public transport would be a very good option)

Okay, I got a ride and I’m a mean selfish bastard.

Permalink Leave a Comment

Fastest way to shut down Windows OS

September 27, 2008 at 7:28 pm (Windows) (, )

Tired of fucking waiting and waiting…. for Windows to shut down. Yeah, I do!

Here’s a way which will shut down Windows completely in few seconds. 

Press Ctrl-Alt-Del to open Windows Task Manager, click on Shut Down menu option and while pressing the Ctrl key, click on the Turn Off option.

Now as you count 1…2….3….4…..5….System Shut Down

Permalink Leave a Comment

Dynamically add element / attribute to a XML using E4X

September 25, 2008 at 12:01 pm (Flex, XML) (, , )

Written for: Flex, ActionScript 3.0

To dynamically add element / attribute to a XML; assume that it already exists in the XML and using the .(dot) operator, pass a value to it.

Here’s an example. Consider the following XML:

var albumXML:XML =
<tracks>
	    <song tracknumber="1">
	        <title>Orgasm Addict</title>
	        <artist>Buzzcocks</artist>
	    </song>
	    <song tracknumber="2">
	        <title>What Do I Get?</title>
	        <artist>Buzzcocks</artist>
	    </song>
	    <song tracknumber="3">
	        <title>I Dont Mind</title>
	        <artist>Buzzcocks</artist>
	    </song>
	    <song tracknumber="4">
	        <title>Love You More</title>
	        <artist>Buzzcocks</artist>
	    </song>
	</tracks>;

To add an additional element of <genre> to the first <song> node, I’ll use the following line of code.

albumXML.song[0].genre = 'Punk';

Similarly to add an attribute of duration to the first <song> node, I’ll use.

albumXML.song[0].@duration = '2:00';
Now if you trace the XML file, it’ll show as:
trace(albumXML);
/*
<tracks>
  <song tracknumber="1" duration="2:00">
    <title>Orgasm Addict</title>
    <artist>Buzzcocks</artist>
    <genre>Punk</genre>
  </song>
  <song tracknumber="2">
    <title>What Do I Get?</title>
    <artist>Buzzcocks</artist>
  </song>
  <song tracknumber="3">
    <title>I Dont Mind</title>
    <artist>Buzzcocks</artist>
  </song>
  <song tracknumber="4">
    <title>Love You More</title>
    <artist>Buzzcocks</artist>
  </song>
</tracks>
*/

Additionally, you can use the following methods of a XML object.

  • appendChild()
  • prependChild()
  • insertChildAfter()
  • insertChildBefore()

Permalink 3 Comments

Sweet Dreams of Roy Buchanan

September 18, 2008 at 6:40 pm (Music) (, , )

Love ya Roy!

Peace.

Permalink Leave a Comment

Kinda makes you think……doesnt it?

September 17, 2008 at 6:49 pm (Gazy) ()

Permalink Leave a Comment

hmmm…Thats easy!

September 12, 2008 at 5:20 pm (Royal Enfield) (, , , )

Found this video on YouTube under the title – “The Art of Starting a Royal Enfield (1)”. Being a hardcore Enfield rider myself, I was expecting a kick start with a lot of back kicks thrown in for that extra punch. What I found in the end was really funny. Check it out.

By the way, only Enfield riders would understand this. Others can just ponder over our amusement!

Permalink Leave a Comment

LHC – Ohh Yeah!

September 12, 2008 at 1:16 am (Science) (, )

I know I’m delayed by a couple of days, but still considering the enormous nature of the project and the scientific significance I would like to say – “Collide those damn particles and lets see what we get!”

Permalink Leave a Comment

Next page »