Sunday, August 15, 2010

Happy Birthday to My Country

Happy Independence Day


Thursday, July 22, 2010

Trader's Goal

A trader’s first goal must be long-term survival; second goal, a steady growth of capital; and your third goal, making high profits. Unfortunately, many traders come to the market with third point as first goal.

Thursday, June 10, 2010

Single/Multi line in one Component in Flex 3

In Flex 3 TextInput component allows single line & TextArea allows multi line text input. Want to have an single component which will allow both., then use below code (component)

SingleMutiLineTextArea.as
package components
{
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.events.TextEvent;
import flash.ui.Keyboard;
import mx.controls.TextArea;

public class SingleMutiLineTextArea extends TextArea
{
public function SingleMutiLineTextArea()
{
super();
this.addEventListener(TextEvent.TEXT_INPUT,onTextInput);
}

private var _multiLine:Boolean = false;

public function set multiLine(value:Boolean):void
{
multiLine = value;
}

public function get multiLine():Boolean
{
return _multiLine;
}

private function onTextInput(event:TextEvent):void
{
if (!_multiLine && (event.text.charCodeAt() == 10 || event.text.indexOf(String.fromCharCode(10))!=-1))
{
event.preventDefault();
}
}
}
}


If the property 'multiLine' is set to 'true' it accepts multiline entering of text., if it is set to 'false' it wont allow.

Leave you comments below if found useful

Saturday, May 8, 2010

My Musings with/on my bike

My bike was stolen in Bangalore on a night of April when I went to my hometown. Totally 12 bikes are there where I parked mine, but I am LUCKY person to lose bike. Still I didn’t know why the thief took my 6 year old bike leaving 2 months old ones which were parked with mine. On next day I went to my nearest police station and informed them regarding this.


The first thing I learnt here is in every police station there is ONLY ONE person with whom we had to deal regarding these stolen/theft cases.


The police whom I met told that he will file an FIR if I want it for insurance or else he will just take a complaint. I too agreed for this as I had to search for my insurance papers. So I just gave details regarding mine & my bike and left that place.


After a few days I was informed that my bike was found but in an another police station.


I neither given complaint nor filed FIR upto now but it was found., kudos to the investigation abilities of police.


I was asked to bring FIR copy first. So I went to the police station where I informed regarding this and got an FIR.


The cost I got incurred is RS.200 that too the police didn’t asked/insisted directly, (seems he’s a contract employee or a good one) but based on his facial feelings I myself given him the amount.


Then I took the FIR to the police station where my bike was there.


Here also everybody pointed me to only one person who dealt with this particular issue (stolen goods).


I expected he will ask for some money and will give my bike immediately. But he told me an (long) actual procedure to get my own bike back from them. I am not sure about the exact procedure but the procedure tentatively is as follows:


First they will file some case and inform the court that they arrested some thief and recovered this number of bikes (there are many bikes recovered with mine).

Then a complaint number (he told a name for this) is generated.

Then I had to take this number to the court and file an appeal to them that the police had recovered an vehicle with its registration/engine/chassis number and the bike is mine for which I had show proofs like my original RC book etc. They told for this I had to hire a lawyer. Then the court will give us a “Release Order” which we had to submit in the police station to get our bike release from them.


(I heard we can get a lawyer(for 1000rs but not sure about the actual cost) who will complete the process and get us the “Releasing Order”. May be the police people will have those lawyer numbers )


The police told me about this procedure and told me to come next week as they are dealing with “laptop theft/recovery” cases in that week and gave me his number for further communication.


In the next week I called that police daily but he told they are still dealing with laptop cases and bike cases are not still taken up.


After one week he told me to come on next Wednesday and he will tell me the actual process/ formalities and I can get my bike on that next day. So I went to the police station on next Wednesday but he was on leave, and every other police man told he is the point of contact for these stolen cases. His cell was switched off and it took me another 5 days to get him on cell. He told me to come on next Monday with an “Indemnity Bond” paper.


See point number 22 in this link: http://www.ksp.gov.in/static/citizen-charter/

P.S: “Indemnity Bond papers in Bangalore are available with STOCK HOLDING CORPORATION OF INDIA”.

Locations: http://www.shcilestamp.com/estamp_statekarnataka.html#shcilbranchkarnataka


On next Monday he simply took an printed statement on that bond with my signature and gave my bike back :-)


The entire printed matter was in Kannada which I couldn't understood a single line but kept the signature.


It took 1800 bucks to get my bike here and the police are very frank in these matters.


I got my bike exactly after one month I lost it and it took exactly 14 days to take it out of police station.

The doubt is when there is an easy process like this why did the police insisted on a long process (through court) which will take a long time!!! Although we went through court then also the cost will be almost same where we had to more for lawyer and less for police


P.S: But it took 6000 bucks to repair the bike and bring it into normal condition. The battery & petrol were taken off. Seems nothing left to peel from it.


Everybody says I am lucky to get my bike back. But if the bike was not found I may have saved a 8000 bucks of expenses and may get around 15k-20k as insurance claim (but it will take time). with around 20k-25k I can buy a better bike then mine.


NOW THE DILEMMA : IS I AM UNLUCKY TO LOSE MY BIKE OR LUCKY TO GET MY BIKE BACK OR IT WAS WRITTEN (fate) THAT I HAD TO REVOLVE AROUND TWO POLICE STATIONS FOR ONE MONTH???

Friday, March 26, 2010

Dispatching Events from Popups in FLEX

Sometimes we don't know (or forget) some silly things. Today I required to dispatch an custom event from a popup and handle that in component (parent mxml) in/on which that popup was opened. I normally used this line in popup:

this.dispatchEvent(new Event("myEvent"));

and handled this in the parent(of popup) mxml as:

this.addEventListener("myEvent",myEventHandler);

private function myEventHandler(event:Event):void
{
Alert.show("I came here");
}

While looking everything is fine but the (intended) functionality didn't worked.
i.e the event was fired but the Alert(event handler) was not executed.

I spend some 1 hour on this thinking any typo error is there.

Then I opened GOOGLE mahatma and searched for this
(I scolded myself why I didn't done this at first itself)

The first two results itself told all the story.

The first link said:
"DisplayObjects created through the PopupManager.createPopup() function are not children of the application container"
i.e popups are not children of Application container so the 'event' dispatched in popup can't be handled in its parent.

http://www.munkiihouse.com/?p=45

The second link gave me the solution:

Add the listener to popup while creating it in parent(mxml).

var myPopupObj:MyPopUp = PopUpManager.createPopUp(this,MyPopUp);
myPopupObj.addEventListener("myEvent",myEventHandler);
//This is where everything lies. Assign eventlistner for popup

Now dispatch the event(myEvent) as usually from the popup and it will be handled in its parent mxml(myEventHandler);

http://matthijs.stichelz.be/blog/2008/12/dispatch-custom-events-from-popup/

May this is an small thing but its useful.