Function Proxy for ActionScript 3
In all my AS2 work, I depend heavily on Person 13's Proxy Class, which allows you to create a reference to a function and pass in a dynamic number of arguments. This technique is very useful for setting up event handlers and callback functions in situations where you don't want to deal with the overhead of setting up an event listener architecture for your application.
As I'm transitioning to Flex, I've found that I just can't live without Proxy, so I've rewritten the code for AS3. For clarity, I've renamed it "FunctionProxy", since there is already a Proxy Class in AS3. Also, note the use of the ... (rest) parameter, which replaces the Function.arguments array from AS2.
The beauty of it is that it's now only 5 lines of code!
As I'm transitioning to Flex, I've found that I just can't live without Proxy, so I've rewritten the code for AS3. For clarity, I've renamed it "FunctionProxy", since there is already a Proxy Class in AS3. Also, note the use of the ... (rest) parameter, which replaces the Function.arguments array from AS2.
The beauty of it is that it's now only 5 lines of code!
package
{
public class FunctionProxy
{
public static function create(oTarget:Object, fFunction:Function, ... args):Function {
var fProxy:Function = function():void {
fFunction.apply(oTarget, args);
};
return fProxy;
}
}
}
//Usage
private function quack(num: int, s: String ): void{
trace("hello" + num + " " + s);
}
var f: Function;
f = FunctionProxy.create(this, quack, 1, "duck");
f();
//outputs "hello1 duck"
24 Comments:
Watch out for closures ;)
private function quack(num: int, s: String ): void
{
trace("hello "+ this.name + ":" + num + " " + s);
}
function doWin ():void
{
var o:Object = new Object();
o.name = "It's me!";
var f:Function = FunctionProxy.create(o, quack, 1, "duck");
f();
By
maliboo, at 10:18 AM
Thanks for this. I'm trying to load the name of function from a database and put it into a addeventlistner. for example: thebutton.addEventListener(FlexEvent.BUTTON_DOWN,"thefunctionfrom thedatase").
Any ideas will be helpful.
Thanks
-Luis
By
Anonymous, at 4:49 PM
thanks man, this is really usefull.
By
Anonymous, at 10:39 AM
wow power leveling
wow powerleveling
world of warcraft power leveling
ffxi power leveling
ffxi powerleveling
ffxi
ffxi gil
age of conan
lotro powerleveling
lotro power leveling
lotro goldwow power leveling
wow powerleveling
world of warcraft power leveling
ffxi power leveling
ffxi powerleveling
ffxi
ffxi gil
age of conan
lotro powerleveling
lotro power leveling
lotro goldwow power leveling
wow powerleveling
world of warcraft power leveling
ffxi power leveling
ffxi powerleveling
ffxi
ffxi gil
age of conan
lotro powerleveling
lotro power leveling
lotro goldwow power leveling
wow powerleveling
world of warcraft power leveling
ffxi power leveling
ffxi powerleveling
ffxi
ffxi gil
age of conan
lotro powerleveling
lotro power leveling
lotro goldwow power leveling
wow powerleveling
world of warcraft power leveling
ffxi power leveling
ffxi powerleveling
ffxi
ffxi gil
age of conan
lotro powerleveling
lotro power leveling
lotro goldwow power leveling
wow powerleveling
world of warcraft power leveling
ffxi power leveling
ffxi powerleveling
ffxi
ffxi gil
age of conan
lotro powerleveling
lotro power leveling
lotro goldwow power leveling
wow powerleveling
world of warcraft power leveling
ffxi power leveling
ffxi powerleveling
ffxi
ffxi gil
age of conan
lotro powerleveling
lotro power leveling
lotro goldwow power leveling
wow powerleveling
world of warcraft power leveling
ffxi power leveling
ffxi powerleveling
ffxi
ffxi gil
age of conan
lotro powerleveling
lotro power leveling
lotro gold
By
wow power leveling, at 11:12 PM
runescape money runescape gold runescape gold runescape money buy runescape gold buy runescape money runescape money runescape gold wow power leveling wow powerleveling Warcraft Power Leveling Warcraft PowerLeveling buy runescape gold buy runescape money runescape items runescape accounts runescape gp dofus kamas buy dofus kamas Guild Wars Gold buy Guild Wars Gold lotro gold buy lotro gold lotro gold buy lotro gold lotro gold buy lotro gold runescape money runescape power leveling runescape money runescape gold dofus kamas cheap runescape money cheap runescape gold Hellgate Palladium Hellgate London Palladium Hellgate money Tabula Rasa gold tabula rasa money Tabula Rasa Credit Tabula Rasa Credits Hellgate gold Hellgate London gold wow power leveling wow powerleveling Warcraft PowerLeveling Warcraft Power Leveling World of Warcraft PowerLeveling World of Warcraft Power Leveling runescape power leveling runescape powerleveling eve isk eve online isk eve isk eve online isk tibia gold Fiesta Silver Fiesta Gold SilkRoad Gold buy SilkRoad Gold runescape accounts buy runescape accounts rs2 accounts buy rs2 accounts runescape power leveling rs2 power leveling FFXI Gil buy FFXI Gil gaia gold buy gaia gold buy dofus kamas buy dofus kamas dofus kamas runescape accounts buy runescape accounts rs2 accounts buy rs2 accounts runescape power leveling rs2 power leveling rs2 gold buy rs2 gold runescape
By
Anonymous, at 6:13 PM
runescape money runescape gold tibia item tibia gold runescape accounts tibia money runescape gp buy runescape gold tibia gold tibia item buy runescape money runescape items tibia money
By
Anonymous, at 12:12 AM
???
???
??????
??
???
???
????
????
???
???
???
??????
??
???
???
???
????
????
????
???
???
????
????
????
?????
????
?????
?????
?????
?????
????
???
????
????
?????
?????
????
?????
?????
?????
???
??
???
??
???
???
??????
???
????
???
???
???
?????
???
???
????
???
???
???
????
????
?????
?????
?????
???
???
????
????
????
???
?????
?????????
???
?????
???
????
????
????
????
????
?????
????
????
???
??????
???
????
???
???
?????????
???????
????
??A???
????
?????
?????
??
????
????
???
???
??????
???
???
???
?????????
???????
????
????
????
????
????
?????
????
????
???
??????
???
????
???
???
?????????
???????
????|??A???
????|??B???
????|?????|?????
???|????|???|??
??|????|??
???|??
???|???|??????|???|???
????????????????
???|?????????|???????
????
??A???
????
??B???
????
?????
?????
???
????
???
??
????
????
???
??
???
???
??????
???
???
????
?????
?????
?????????
?????
??
????
????
????
????
????
????
????
????
?????
????
?????
????
??
???
???
????
??
???
????
????
???
???
??????
???
?????
?????
???
???
???
????
?????
?????
??
?????????
???????
???????
??????
????
?????
???
?????
?????
???
?????
?????
???
???
???
?????
?????
???
???
???
???
????
????
????
????
????
?????
????
????
???
??????
???
????
???
???
?????????
???????
????
??A???
????
??B???
????
?????
?????
???
????
???
??
????
????
???
??
???
???
??????
???
???
????
?????
?????
?????????
?????
??
???
????
????
????
????
????
????
??
???
????
???
???
??????
???
???
??????
?????
???
???
??????
?????
???
???
??????
?????
???
???
???
???
??????
??????
?????
?????
???
???
??????
?????
???
???
??????
?????
???
???
??????
???
???
???
???
??????
??
??
??
??
???
????
????
????
????
??
????
???
????
???
??
???
???
????
????
??
???
???
????
????
??
??
???
???
???
???
????
????
????
????
??
???
???
????
????
??
???
???
????
????
??
???
???
????
????
??
??
??
???
????
??
????
??
????
????
??
????
????
???
??
????
????
???
????
??
????
????
???
????
??
??
????
????
????
????
???
???
????
????
??
??
????
????
????
????
???
???
????
????
??
??
??
????
????
????
????
????
????
???
???
???
????
????
????
??
??
??
????
????
????
????
????
???
???
????
????
??
??
??
??
?????
????
??
?????
?????
?????
?????
?????
????
?????
???
????
?????
????
?????
?????
?????
????
????
?????
????
????
????
??4S???
?????
???
????
????
????
????
????
???
????
????
????
????
????
???
????
????
????
????
????
????
????
???
????
????
??
??
By
Anonymous, at 12:43 AM
money talks -
monsters of cock -
mr big dicks hot chicks -
mr cameltoe -
mr chews asian beaver -
my first porn scene -
orgy ental -
ox pass -
panties and fannies -
papi -
pee lover -
penis palooza -
phat booty brazil -
phat booty hoes -
phat white booty -
pimp my black teen -
please bang my wife -
porn multi pass -
public invasion -
pussy foot girls -
pussy pinata -
real arizona amateurs -
reality pass plus -
real orgasms -
red ass teens -
round and brown -
round mound of ass -
sado slaves -
sammy4u -
sapphic erotica -
see her squirt -
she fucks guys -
street blowjobs -
street ranger -
summer time milf -
sweet auditions -
sweet loads -
taylor bow -
team squirt -
teenie video -
teeny bopper club -
the big swallow -
the dirty old man -
thugs and juggs -
tight buttholes -
tinys black adventures -
tranny surprise -
tug jobs -
vip crew -
we live together -
white slave whores -
whore wagon -
xxx proposal -
tgirl island -
2 in the stink -
8th street latinas -
40 inch plus -
abbraxa porn -
adult friend finder -
all reality pass -
all sites access -
all star porn girls -
angels of porn video -
asian creamy pies -
ass parade -
athens girls -
bait bus -
ball honeys -
bangbros network -
bang bus -
barefoot maniacs -
big ass adventure -
big cock teen addiction -
big league facials -
big mouthfuls -
big naturals -
big tit patrol -
big tits round asses -
bikini contest porn -
black creamy pies -
black dicks latin chicks -
black gang white bang -
black mother fuckers -
blind date bangers -
boy girl bang -
boys first time -
brandi belle -
brazil bang -
brick house butts -
bubble butt orgy -
bukkake pee -
busty adventures -
butt cam -
cam crush -
cams -
captain stabbin -
casting couch teens -
coeds need cash -
college teens book bang -
cumfiesta -
cum girls -
dangerous dongs -
euro sex parties -
extreme asses -
extreme naturals -
fat ass pass -
first time auditions -
fisting lessons -
fling -
flower tucci -
french fisting -
french pee -
gag fuck -
ghetto hoochies -
giants black meat white treat -
heels and hoes -
horny spanish flies -
hung like a whore -
im live -
in focus girls -
inter mixed -
in the vip -
i spy camel toe -
its just chocolate -
jake bustsnuts -
knob squad -
kung pao pussy -
lesbian teen hunter -
little coco -
max hardcore porn -
mike in brazil -
milf hunter -
milf lessons -
milf next door -
miss pain -
money talks -
monsters of cock -
mr big dicks hot chicks -
mr cameltoe -
mr chews asian beaver -
my first porn scene -
orgy ental -
ox pass -
panties and fannies -
papi -
pee lover -
penis palooza -
phat booty brazil -
phat booty hoes -
phat white booty -
pimp my black teen -
please bang my wife -
porn multi pass -
public invasion -
pussy foot girls -
pussy pinata -
real arizona amateurs -
reality pass plus -
real orgasms -
red ass teens -
round and brown -
round mound of ass -
sado slaves -
sammy4u -
sapphic erotica -
see her squirt -
she fucks guys -
street blowjobs -
street ranger -
summer time milf -
sweet auditions -
sweet loads -
taylor bow -
team squirt -
teenie video -
teeny bopper club -
the big swallow -
the dirty old man -
thugs and juggs -
tight buttholes -
tinys black adventures -
tranny surprise -
tug jobs -
vip crew -
we live together -
white slave whores -
whore wagon -
xxx proposal -
vengified -
2 in the stink -
8th street latinas -
40 inch plus -
abbraxa porn -
adult friend finder -
all reality pass -
all sites access -
all star porn girls -
angels of porn video -
asian creamy pies -
ass parade -
athens girls -
bait bus -
ball honeys -
bangbros network -
bang bus -
barefoot maniacs -
big ass adventure -
big cock teen addiction -
big league facials -
big mouthfuls -
big naturals -
big tit patrol -
big tits round asses -
bikini contest porn -
black creamy pies -
black dicks latin chicks -
black gang white bang -
black mother fuckers -
blind date bangers -
boy girl bang -
boys first time -
brandi belle -
brazil bang -
brick house butts -
bubble butt orgy -
bukkake pee -
busty adventures -
butt cam -
cam crush -
cams -
captain stabbin -
casting couch teens -
coeds need cash -
college teens book bang -
cumfiesta -
cum girls -
dangerous dongs -
euro sex parties -
extreme asses -
extreme naturals -
fat ass pass -
first time auditions -
fisting lessons -
fling -
flower tucci -
french fisting -
french pee -
gag fuck -
ghetto hoochies -
giants black meat white treat -
heels and hoes -
horny spanish flies -
hung like a whore -
im live -
in focus girls -
inter mixed -
in the vip -
i spy camel toe -
its just chocolate -
jake bustsnuts -
knob squad -
kung pao pussy -
lesbian teen hunter -
little coco -
max hardcore porn -
mike in brazil -
milf hunter -
milf lessons -
milf next door -
miss pain -
money talks -
monsters of cock -
mr big dicks hot chicks -
mr cameltoe -
mr chews asian beaver -
my first porn scene -
orgy ental -
ox pass -
panties and fannies -
papi -
pee lover -
penis palooza -
phat booty brazil -
phat booty hoes -
phat white booty -
pimp my black teen -
please bang my wife -
porn multi pass -
public invasion -
pussy foot girls -
pussy pinata -
real arizona amateurs -
reality pass plus -
real orgasms -
red ass teens -
round and brown -
round mound of ass -
sado slaves -
sammy4u -
sapphic erotica -
see her squirt -
she fucks guys -
street blowjobs -
street ranger -
summer time milf -
sweet auditions -
sweet loads -
taylor bow -
team squirt -
teenie video -
teeny bopper club -
the big swallow -
the dirty old man -
thugs and juggs -
tight buttholes -
tinys black adventures -
tranny surprise -
tug jobs -
vip crew -
we live together -
white slave whores -
whore wagon -
xxx proposal -
throat jobs -
2 in the stink -
8th street latinas -
40 inch plus -
abbraxa porn -
adult friend finder -
all reality pass -
all sites access -
all star porn girls -
angels of porn video -
asian creamy pies -
ass parade -
athens girls -
bait bus -
ball honeys -
bangbros network -
bang bus -
barefoot maniacs -
big ass adventure -
big cock teen addiction -
big league facials -
big mouthfuls -
big naturals -
big tit patrol -
big tits round asses -
bikini contest porn -
black creamy pies -
black dicks latin chicks -
black gang white bang -
black mother fuckers -
blind date bangers -
boy girl bang -
boys first time -
brandi belle -
brazil bang -
brick house butts -
bubble butt orgy -
bukkake pee -
busty adventures -
butt cam -
cam crush -
cams -
captain stabbin -
casting couch teens -
coeds need cash -
college teens book bang -
cumfiesta -
cum girls -
dangerous dongs -
euro sex parties -
extreme asses -
extreme naturals -
fat ass pass -
first time auditions -
fisting lessons -
fling -
flower tucci -
french fisting -
french pee -
gag fuck -
ghetto hoochies -
giants black meat white treat -
heels and hoes -
horny spanish flies -
hung like a whore -
im live -
in focus girls -
inter mixed -
in the vip -
i spy camel toe -
its just chocolate -
jake bustsnuts -
knob squad -
kung pao pussy -
lesbian teen hunter -
little coco -
max hardcore porn -
mike in brazil -
milf hunter -
milf lessons -
milf next door -
miss pain -
money talks -
monsters of cock -
mr big dicks hot chicks -
mr cameltoe -
mr chews asian beaver -
my first porn scene -
orgy ental -
ox pass -
panties and fannies -
papi -
pee lover -
penis palooza -
phat booty brazil -
phat booty hoes -
phat white booty -
pimp my black teen -
please bang my wife -
porn multi pass -
public invasion -
pussy foot girls -
pussy pinata -
real arizona amateurs -
reality pass plus -
real orgasms -
red ass teens -
round and brown -
round mound of ass -
sado slaves -
sammy4u -
sapphic erotica -
see her squirt -
she fucks guys -
street blowjobs -
street ranger -
summer time milf -
sweet auditions -
sweet loads -
taylor bow -
team squirt -
teenie video -
teeny bopper club -
the big swallow -
the dirty old man -
thugs and juggs -
tight buttholes -
tinys black adventures -
tranny surprise -
tug jobs -
vip crew -
we live together -
white slave whores -
whore wagon -
xxx proposal -
honey chest -
18 interracial -
8th street latinas -
adult dating friends -
adult friend finder -
adult love line -
adult movie max -
all reality pass -
all sites access -
a lucky stranger -
anal destruction -
ashley lightspeed -
asian love line -
asian nudes -
ass parade -
ass to mouth angels -
bait bus -
ball honeys -
bangbros network -
bang bus -
bare foot maniacs -
barely legal -
big cock teen addiction -
big league facials -
big mouthfuls -
big naturals -
big tit patrol -
big tits round asses -
bikini hookups -
black cocks tiny teens -
boys first time -
boys gone bad -
brandi belle -
brandy didder -
britney lightspeed -
budapest bang -
busty adventures -
captain stabbin -
casting couch teens -
circle jerk boys -
coeds need cash -
college party dates -
college teens bookbang -
courtney lightspeed -
cumfiesta -
dana lightspeed -
dirty aly -
dirty schoolgirl -
drunk party orgies -
easy drunk girls -
ebony love line -
erica lightspeed -
euro fuck toys -
euro sex parties -
extra big dicks -
extreme asses -
extreme naturals -
facial humiliation -
faith lightspeed -
female pov -
first time auditions -
gangbang divas -
giants black meat white treat -
gigi lightspeed -
heather lightspeed -
heels and hoes -
her first throatjob -
hood hunter -
horny spanish flies -
hungarian butt sluts -
im live -
in focus girls -
in the vip -
i spy camel toe -
jordan capri -
lacey white -
latin love line -
lesbian teen hunter -
lesbo 101 -
lightspeed 18 -
lightspeed dvds -
lightspeed girls -
lightspeed sorority -
lightspeed tv -
lightspeed university -
lightspeed world -
little troublemaker -
lonely wives dating club -
mandy lightspeed -
man hookups -
meaty man movies -
men over 30 -
mike in brazil -
mikes apartment -
milf challenge -
milf hunter -
milf internal -
milf lessons -
milf next door -
milf whore -