Validating real/integer numbers in 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>
AS3.0: Add one or more elements to the begining of an array
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
Bombay – (Rickshaw or Taxi) = Beautiful 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.
Fastest way to shut down Windows OS
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
Dynamically add element / attribute to a XML using E4X
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';
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()
hmmm…Thats easy!
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!
LHC – Ohh Yeah!
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!”

