Wednesday, April 15, 2009

Removing anonymous function from an event listener

Hey guys and gals, quick lesson in flex. One popular thing to do is use something called an anonymous function with eventListeners when you want to pass the function something more than just the event. You would typically just say:

myObj.addEventListener(Event.ENTER_FRAME, function(a_event:Event):void{someotherFunc(a_event, additionalArgs);});

But this sucks if you are going to want to remove the listener. So something you can do is the following. You can create a function variable (func), then set the anonymous function to this var. Then the second function that you ultimately want to call (func2) will have an optional parameter ‘myHackFunc’ that will be the variable that you created (func). Then you just call remove event listener on ‘myHackFunc’.

I have heard of other ways of doing this, mainly, using ‘arguments.callee’ This causes my app to die, but the way described above, and shown below, seems to work all the time. Hope it helps!


public function myFunc1():void{
var func:Function = function(a:Event):void{ func2 (a, some_args, func)};
i.addEventListener(Event.ENTER_FRAME, func);
}

public function func2(a_event:Event, some_args:*, myHackFunc:Function = null):void{
a_event.currentTarget.removeEventListener(Event.ENTER_FRAME, myHackFunc);
}


Oh, or you could just go and use a custom event class... but that isn't the point of this exercise :P

Friday, February 13, 2009

1234567890




So as you may or may not know today (2/13/09) at 5:31 PM EST we will have the time of 1234567890 in unix time. This is the number of seconds that has taken place since January 1st 1970 at midnight GMT. Above will show you if the time has passed, this is a little script that took 5 minutest to right, that will be 'screen shoted' later today so I will know where i was in my life at 1234567890... sitting alone in front of my computer watching a stupid flex app. None the less.. enjoy :D

Thursday, February 12, 2009

Reason number 193 i love my job

Getting to put my face on alllll sorts of random things... for testing :P

Wednesday, February 4, 2009

Angry Dog Stripper

This is the final product of my latest product at work. It is called Be a Star. Basically, you upload a photo, add crazy assets and we insert it in to the movie that you choose. Many laughs were had during this product. Found on www.webfetti.com and www.myfuncards.com



--------------------------- :: EDIT:: ---------------------------
A company sent a cease and desist to our company because apparently they hold a patent on 'Dynamicaly Adding a head to an animated body' Who knew you could hold a patent on a fucking idea. As a result we had to pull one of the shining features on this product. At any rate, We have pulled the assets and the movie, but you can visit www.webfetti.com and www.myfuncards.com and check it out 'Be a Star'

Wednesday, November 12, 2008

AS3

Hey there guys and gals, here is a function that will find the function that is calling it. This is in AS3 It is great for debugging and quite reliable. I use this when I want to make my own custom errors. Enjoy

currFunction(){
return new Error().getStackTrace().toString().substring( new Error().getStackTrace().toString().indexOf("/") + 1, new Error().getStackTrace().toString().indexOf("["));
}

Wednesday, November 5, 2008

::cough::: new post ::cough::

Sunday, August 24, 2008

Day 4 5 6

4 - 59 minutes 28 seconds

5 , 6, 7 no running... my bones literally hurt and my knee has been going out. I tried to do it again, but i think i am fucking up my left knee. For those of you who know me, my first car accident fucked up that knee, and i am afraid that this isn't going to work. Therefore I think i am going to walk home every day from work (5 - 6miles) rather than jogging / walking the 4.5 I think its a fair trade. this will start tomorrow

Wednesday, August 20, 2008

day 3

27 more days, i checked out how far i am actually going and its about 4.5 miles. Today I did it in 59 minutes 30 seconds :P

I have started jogging for a minute, walk 3 repeat
I don't think there is a part of me thats not sore:P maybe my eye lids.... but even they are hating me... 28 more days

Tuesday, August 19, 2008

day 2

59 minutes 57 seconds...

my ass hurts
my legs hurt
fucking pads on my foot hurt like a mother fucker

however, i learned a valuable lesson today, sprinting != jogging

[Edit]
Do i have bruises on the bottom of my feet? ... is that bad?