Ask a Question related to Macromedia Director Lingo, Design and Development.
-
Nicollini webforumsuser@macromedia.com #1
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
-
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... -
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 -
#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: ... -
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... -
DataGrid - problem with calling handler for BoundColumn
Yes I have it there in page_load event but it doesn't work... page_load event. -
SafariTECH #2
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
-
Luke #3
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
-
Stephen Whipp #4
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...other location are made in their own members as "Movie Scripts", not> the easiest way is to make sure the handlers that can be called from any
behaviours.fashion.>
> 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>
>
>
> ============================
> Glen Palmer
> SafariTECH
> Cold Fusion Specialist
> [url]www.safaritech.com[/url]
> ============================
Stephen Whipp Guest



Reply With Quote

