Passing arguments to event listeners in AS3

AS3 does not have a direct option to send arguments to event listeners. A lot of times we come across situations where it is important to pass some data to the listener.

Though not out of the box, A separate class can be created and used to achieve this functionality. This class will act as an intermediary which will store the data and in turn will deliver it to the listener.

Have a look at the sample code below

var ea:EventArguments = new EventArguments(handleClick, { arg1:”Hello”, arg2:var1 });

private function handleClick(e:Event, ob:Object) {
// ob is the argument object

The EventArguments object saves in itself the argument object and a reference to the listener handleClick. The method call in EventArguments object is assigned as listener which will in turn call the final handleClick with arguments. Below is the class definition.

{code type=”javascript”}
package cb.util

public class EventArguments

private var callBack:Function;
private var arg:Object;

public function EventArguments(aCB:Function, aOB:Object) {
callBack = aCB;
arg = aOB;

public function call(e:*) {
callBack(e, arg);



This class is created to send one object as an argument. A custom EventArguments class can be created as per requirement. It should be noted that over usage of this technique might result in memory leaks of EventArguments objects as they are not deleted. However this workaround can be used as an alternative instead of changing the application architecture.

10 reasons why Gayle is the best

I believe Chris Gayle is definitely the most destructive batsman ever. With his cool and calm attitude the fun multiplies.

Here is an article I found online.

1. Yesterday, Chris Gayle scored his second 100 in the IPL4. Second in the IPL4. You probably couldn’t score 100 in junior school league. He scored first hundred after having just stepped off a plane from the West Windies.

2. Gayle can cut to wherever he wants with clinical precision. Try cutting a potato. Or an onion. You hurt yourself, didn’t you? Yeah. Gayle can hit the ball so hard, it actually goes back in time. Some people believe that every catastrophic event that ever occurred was a cricket ball that was hit back in time by Chris Gayle.  Others say the thing that fell on Newton’s head was actually a cricket ball hit back in time by Gayle.  [hat-tip @GreigDugg]

3. Gayle has a heart condition.  It’s something a little bit like a heart murmur. He says that it’s nothing serious, it’s just that sometimes when you overwork the body then your heart begins to race gradually. Which is why he doesn’t really like running all that much and prefers to just hit sixes. When life gives you lemons and all of that. What was so terrible about your life again?

4.  Gayle said no to a central contract. The WICB then said no thanks to his services. So he raised a big middle finger to them.  Twice. And he makes the world feel inadequate about their abilities. All. The. Time.

5. Gayle bowls with his sunglasses on. At night.  He can also start a fire with a magnifying glass. At night.

6. He’s Chris Gayle, bitch.

7.  He can Tweet the most obscure random rubbish and use expressions nobody has never heard before and you’ll still nod and say yes, yes it is. It’s Sweet Azz. Kiss teeth!

8.  Parents don’t like having their kids watch Chris Gayle bat because they are worried that it will give them nightmares. Forget the bogeyman and the tokkelosh, Gayle will inspire nightmares in children for generations to come. Parents don’t want their kids to watch him because they will never want to become bowlers. Bowlers who were caught in a Gayle Force Storm are said to never recover. They wake up in cold sweats while holding themselves and reciting Barry White lyrics for the rest of their lives.

9. Those who don’t do it for Sachin, do it for Gayle.

10. It took him about 50 minutes to score his 107. That’s the same amount of time a Grey’s Anatomy episode takes and he was more entertaining in those 50 minutes than Grey’s has been in its entire 4000 seasons. Tell your girlfriend to put that in her pipe and smoke it.

Original article