-
calling Functions with a variable
Hi,
Is there any way to call a function whose name is returned by a variable.
say for example if u have three functions
function function1(){
trace("function 1");
};
function function2(){
trace("function 2");
};
function function3(){
trace("function 3");
};
and there is a variable x whose values will be "function1","function2","function3"
the question is ..... is it possible to execute the function by value x
like call(x); or something of that sort.
Please get back ASAP.
Regards
Venkat
-
Live And Let Live All
Try this one...
Hi JV
what I understand , you want to call a function depending upon the value of the variable.
check the value of the variable in loop or make it an array.
Code:
if(yourVarable[Func 1] =="function1"){
function1();
}else if(yourVarable[Func 2] =="function2"){
function2();
}else if(yourVarable[Func 3] =="function3"){
function3();
if this doesn't solves your problem..
try attaching the file
______________________________________________
-
Hi sutar,
Thanks for your reply.....
is there anything other than this nested if's ... cos I want this code to run in an onEnterFrame code... now if I put this it will severly degrade the performance ... which is why in the first case I asked for the call method.... any suggestions
V E N K A T
~~~~~~~~~~~~~~~~~~~~~~~
BEGIN WITH END IN THE MIND
-
Live And Let Live All
try using for loop
JV try a loop
Code:
for(i=0;1<yourVarable.length; i++){
if(yourVarable[eval("Func "+i)] == "function"+i){
call(eval(function"+i+"()"));
break;
}
______________________________________________
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|