call functions dynamically

Ask a Question related to Macromedia Flash Actionscript, Design and Development.

  1. #1

    Default call functions dynamically

    i am having some trouble calling functions dynamically.

    i want to load data into pages as they are called. i therefore have a function
    called initialisePage(pageName). i want to use this function in turn to call
    initialisation functions for each page. these functions are called
    firstContent(), secondContent(), thirdContent() etc... i have tried the syntax
    eval(pageName+"Content()"); inside the initialisePage() function, but it
    doesn't work. what am i doing wrong?

    thanks.

    turbomerl Guest

  2. Similar Questions and Discussions

    1. How can I call MFC functions from Perl
      Hello, How can I call MFC functions from Perl? Which module / method I should select? Inline:C ? Inline:CPP ? XS ? or SWIG? Regards, Sankaran
    2. Call/Declare Functions
      I've got a movieclip that has some various functions declared inside of it like init(), etc...those work great. Then inside of that movieclip I have...
    3. Problem with dynamically generated and named functions
      I'm trying to create a dynamically draw list of names that have rollovers and onmousedowns (like a datagrid list type thing), but done in my style...
    4. How to dynamically generate functions in a class
      I am having to be tasked with a rather painful task of updating an existing class by adding a dynamic amount of database field values; for each...
  3. #2

    Default Re: call functions dynamically

    can you make use of this approach ?

    function firstContent(){ trace("1st"); };
    function secondContent(){ trace("2nd"); };

    var1 = "first";
    var2 = "second";
    func = "Content"

    F1 = this[var1+func];
    F1();

    F2 = this[var2+func];
    F2();

    Variable _level0.firstContent = [function 'firstContent']
    Variable _level0.secondContent = [function 'secondContent']
    Variable _level0.var1 = "first"
    Variable _level0.var2 = "second"
    Variable _level0.func = "Content"
    Variable _level0.F1 = [function 'firstContent']
    Variable _level0.F2 = [function 'secondContent']

    hth ?

    Jack. Guest

  4. #3

    Default Re: call functions dynamically

    fwiw - (in MX)
    F1 = this[var1+func]();
    // this fires the trace OK, but the Variable Output is now -
    // Variable _level0.F1 = undefined

    go figure ?? can anyone out there provide enligtenment ?
    Jack. Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139