Ask a Question related to Macromedia Director Lingo, Design and Development.

  1. #1

    Default Calling a handler?

    I'm new to oop so please bare with me, I hope you can answer my question.

    I have a parent script which has an ancestor. I basically want to call a handler from the parent scirpt to where the handler sits (in the ancestor script).

    Or to put another way I need to send a message from the parent script to the ancestor script.

    I've just tryed to call the handler as normal as I thought the handlers within the ancestor were accessible to the object. However I get an error that the handler is not defined.

    Can anyone help???

    Thanks.

    Nick


    Nicollini webforumsuser@macromedia.com Guest

  2. Similar Questions and Discussions

    1. Calling a fuction from a response Handler
      I use a function with remote call to populate a grid with data and it works fine. function getStudentAll() { <cfoutput> var...
    2. Director Mx -- calling a custom handler :(
      please help me....... I m trying to call a custom handler but its not working. The script is on mouseUp me -- custom handler on props end
    3. #25217 [NEW]: calling ob_gzhandler after modified buffer in ob handler, return origin buffer
      From: Xuefer at 21cn dot com Operating system: win PHP version: 4.3.3RC4 PHP Bug Type: Output Control Bug description: ...
    4. DataGrid's UpdateCommand event handler and CancelCommand handler problem
      I am having the same problem: the wrong event handler is being fired when column headings and page changes are clicked. I am using the datagrid...
    5. DataGrid - problem with calling handler for BoundColumn
      Yes I have it there in page_load event but it doesn't work... page_load event.
  3. #2

    Default Re: Calling a handler?

    the easiest way is to make sure the handlers that can be called from any other location are made in their own members as "Movie Scripts", not behaviours.

    Then you can call them just by stating the handler name.

    You can also use Handlers to RETURN data back to a variable in a similar fashion.



    ============================
    Glen Palmer
    SafariTECH
    Cold Fusion Specialist
    [url]www.safaritech.com[/url]
    ============================
    SafariTECH Guest

  4. #3

    Default Re: Calling a handler?

    > I've just tryed to call the handler as normal as I thought the handlers
    within the ancestor were accessible to the object. However I get an error
    that the handler is not defined.

    There are two ways of 'calling handlers' in Director:

    (1) The 'functional' way where you just call the handler like this

    handlerName()

    with no reference to the object with the handler. In this case, Director
    first looks in the current script (whether it is a movie script, parent
    script or behaviour) to see if there is a handler with that name. If not, it
    then goes and looks in all the movie scripts until it finds that handler. If
    it cannot, if generates a "Handler not defined" error.

    (2) The second way is more 'object-orientated'. In this case, you 'call a
    handler' by "sending a message to an object". To do this, you must specify
    which object has the handler. There a numerous ways of doing this

    object.handlerName()
    handlerName(object)
    call(#handlerName, object)
    sendSprite(1, #HandlerName)
    etc

    In each of these examples, you are specifying which object has the
    handler.When Director evokes the handler, it always passes a reference to
    the object that was sent the message as the first parameter. By convention,
    this first parameter is called "me" (or "this" or whatever you want).

    What happens when an object has an ancestor is that any messages sent to the
    object (which that object cannot respond to) are passed 'up the inheritence
    chain' to the object's ancestor. When this occurs, the descendant object
    (the object that originally received the message) 'becomes' the ancestor
    object for the purposes of responding to the message (and the "me" parameter
    in the ancestor will point to the decendant object when it handles the
    message sent to the descendant).

    So, to call the handler (or "method", as they are called in OOP terminology)
    of the ancestor from the descendant, you can do any of the following:

    me.HandlerName()
    -- if the current object ("me") doesn't have a handler called "handlerName"
    then object will use the ancestor's method (the "me" in the ancestor's
    method will point to the descendant)

    ancestor.HandlerName()
    -- in this case, you are specifying the ancestor object as the recipient of
    the message (the "me" in the ancestors method will point to the ancestor)

    callAncestor(#HandlerName, ancestorObject)
    -- use this syntax when the ancestor and the descendant have a method with
    the same name but you do want the descdant to over-ride the ancestor's
    method but still want call the ancestor's method as if it were inherited
    like example 1)

    HTH

    Luke


    Luke Guest

  5. #4

    Default Re: Calling a handler?

    Yeah but this defeats the purpose of programming in an object oriented
    style. The Advantage of using parentScripts/behaviors is that you can a,
    share common functions/data between similar entities b) you can create many
    objects with the same code but having different data (wthout having to
    handle large list of their data manually) an c) you can reuse handler names
    because they are handled by context thereofre making the code easier to
    follow becuase you dont need very long or meaningless identifiers.

    SafariTECH <contact@safaritech.com> wrote in message
    news:bj7gbq$fcp$1@forums.macromedia.com...
    > the easiest way is to make sure the handlers that can be called from any
    other location are made in their own members as "Movie Scripts", not
    behaviours.
    >
    > Then you can call them just by stating the handler name.
    >
    > You can also use Handlers to RETURN data back to a variable in a similar
    fashion.
    >
    >
    >
    > ============================
    > Glen Palmer
    > SafariTECH
    > Cold Fusion Specialist
    > [url]www.safaritech.com[/url]
    > ============================

    Stephen Whipp 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