A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: call function from argument

  1. #1
    Senior Member
    Join Date
    Aug 2001
    Location
    Egypt
    Posts
    332
    hi,
    i need to call a function, whose name is a variable...
    (exactly like the setClickHandler() function for the PushButton Component)

    example:
    Code:
    function check(funcCall) {
      if(whatEver) {
    // i need to call function whose name is the funcCall parameter
      }
    }



    hope you understand what i mean
    thanx in advance..

  2. #2
    Member
    Join Date
    Apr 2002
    Location
    Nevada
    Posts
    57
    if the funcCall is only a string, then you have to use something like:
    Code:
    movieClipThatHoldsTheFunction[funcCall]();
    If the funcCall is the actually reference to the function then just do this:
    Code:
    funcCall();
    Of course add any parameters you need in the ().

    Hope that helps.

  3. #3
    Senior Member
    Join Date
    Aug 2001
    Location
    Egypt
    Posts
    332
    hi,
    i got it..
    you just have to use Function.call()..

    regards,

  4. #4
    Senior Member
    Join Date
    Jun 2002
    Posts
    145
    like this:

    myFunction(myVar){
    gotoAndPlay(myVar);
    }


    then using this command:

    myFunction(5);


    would make the movie goto and play frame 5

  5. #5
    Senior Member
    Join Date
    Aug 2001
    Location
    Egypt
    Posts
    332
    hi,
    that's not i wanted.. but i already got it.. i said it in the last reply

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center