3 Replies Latest reply on Jun 9, 2011 1:39 PM by Ned Murphy

    can't find this function (psuedo) 'call'

    bbxrider11

      a script  I have inherited uses this code for initializing and processing all the fields on a form

       

      firstNameHelp_mc.onRelease = function() {
          _parent.fieldID = "firstName";
          _parent.setHelp();

       

      there is no function named 'function', I wouldn't  think so anyway with reserved names etc.

       

      is this the equivalent of declaring a function on  the fly so to speak, almost like a property get? if so what is the point?

      this is a way for performing multiple actions on some thing like a release with having to create a 'real' function for each one?

        • 1. Re: can't find this function (psuedo) 'call'
          Ned Murphy Adobe Community Professional & MVP

          It is one way of assigning a function to the various "on..." handlers associated with objects.  Buttons and movieclips (and objects in general) have various "on..." handlers associated with them that you can make use of by assigning functions to them.

           

          And it is also a way you could dynamically assign a function to an object that is dynamic, such as a movieclip.  The ability to dynamically assign properties and methods to things is a handy feature, particularly when you get into working with quanitities of objects being assigned properties and methods in loops, such as setting up entire menues of buttons.

           

          Another way you could have assigned it would have been...

           

          firstNameHelp_mc.onRelease = functionName;

           

          function functionName() {
              _parent.fieldID = "firstName";
              _parent.setHelp();

          }

           

          Which means you could have that function available to be shared by other objects or code segments as well.  So you can either have the function defined to be more globally available or specific only to a particular object.

          1 person found this helpful
          • 2. Re: can't find this function (psuedo) 'call'
            bbxrider11 Level 1

            thanks for the reply

            so you can use it for any properties and methods of any object?

            • 3. Re: can't find this function (psuedo) 'call'
              Ned Murphy Adobe Community Professional & MVP

              To assign new properties dynamically to an object, it requires that the object be a MovieClip (or decendant thereof), which is a dynamic object.  Button symbols are not dynamic objects so they cannot have new properties/methods dynamically added to them.  Buttons do have the various "on(...) methods and some properties that you can assign values to, but you cannot dynamically create new ones for them.

              1 person found this helpful