views:

27

answers:

2

If I plan to implement 100 objects on stage to be listen to mouse and keyboard input, is using "function" call responsive enough? How good does eventlistner work?

A: 

Yes, it's responsive enough but it also depends on what your function will be doing. As an extreme example if each function triggers some heavy computation then you may find it's not responsive anymore.

Furthermore , just don't take my word for it. If speed is a concern, you can easily setup a few tests.

PatrickS
A: 

I'm not sure I understand the question completely - like wtf is a "Function" call (is it a callback?) - but I do think you could potentially lower some overhead by setting up one listener for all your 100 stage objects, as opposed to an anonymous (inline in the listener) version for each one. That kind of thing happens more often than one might think in Actionscript.

Also, PatrickS hit the nail on the head about setting up simple tests. Here's the easiest way

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/utils/package.html?filter_flex=4.1&filter_flashplayer=10.1&filter_air=2#getTimer()

That method gives you the number of milliseconds that've elapsed since the swf's started running. Grab it's value before your test, run your test, the grab the value after and figure out the difference. That's how long it took your function to run. If you are weighing the benefits vs. costs of one approach against another's, then set up two tests and see which is faster.

Montagist