Can I call a function using array index?


i've defined array stores function name, this:

 

var aresetbuttontop:array = new array(resettop1,resettop2,resettop3,resettop4,resettop5);  

 

then have button named"btnresettop" when clicked call 1 of 5 functions stored in above array(aresetbuttontop). functions called @ run-time depending upon conditions. need figure out how can call functions using array index. i'm using following code call function. value of has been calculated.


btnresettop.addeventlistener(mouseevent.click, aresetbuttontop[i]);

 

after doing i'm getting following error when click button:

 

typeerror: error #2007: parameter listener must non-null.
    @ flash.events::eventdispatcher/addeventlistener()
    @ gallerytest_fla::maintimeline/thumbtopclick()

 

note: thumbtopclick() is function inside these codes written.

 

i need find out whether posible in as3 call function name using array index or not. if yes, pleas ehelp me out.

you can that.

 

in case looks out of range. show loop.



More discussions in ActionScript 3


adobe

Comments

Popular posts from this blog

How to decompile jsxbin to jsx

Gavik Photoslide GK2: Not able to upload photos - Joomla! Forum - community, help and support

Phoca Guestbook logger registret bruger af - Joomla! Forum - community, help and support