-
Is it possible to dynamically call a function..1 of 2 functions in the pTest object:
Such as...
//=================
// functions are: myFunction1() and myFunction2()
//
//================
nPick = Math.round(Math.random()) + 1; // 1 or 2
pTest["myFunction" + nPick + "()"];
...or any other variation?
Thanks,
Richard
-
Hi,
try
pTest["myFunction" + nPick]()
Musicman
-
Why not create just one function.. send nPick as an argument and let the function itself handle the dynamics..
--------
function myFunction(nPick){
if (nPick==1){
//do stuff
} else {
//do other stuff
}
}
Call would be:
nPick = int(Math.round(Math.random()) + 1); // 1 or 2
pTest.myFunction(nPick)
mc
-
better yet, why don't you walk down the hall to jeremy's office and ask him! he might know...i heard he does some dynamic function calls. don't tell him i told you.
:P
jeremy
-
Why didn't I think of that...
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
|