178
Chapter 10: Events and Messages
on isOKToAttach
Usage
-- Lingo syntax
on isOKToAttach
me, aSpriteType, aSpriteNum
statement(s)
end
// JavaScript syntax
function isOKToAttach(
aSpriteType, aSpriteNum
) {
statement(s)
}
Description
Built-in handler; you can add this handler to a behavior in order to check the type of sprite the
behavior is being attached to and prevent the behavior from being attached to inappropriate
sprite types.
When the behavior is attached to a sprite, the handler executes and Director passes to it the type
of the sprite and its sprite number. The
me
argument contains a reference to the behavior that is
being attached to the sprite.
This handler runs before the
on getPropertyDescriptionList
handler.
The Lingo author can check for two types of sprites.
#graphic
includes all graphic cast members,
such as shapes, bitmaps, digital video, text, and so on.
#script
indicates the behavior was
attached to the script channel. In this case, the
spriteNum
is 1.
For each of these sprite types, the handler must return
TRUE
or
FALSE
. A value of
TRUE
indicates
that the behavior can be attached to the sprite. A value of
FALSE
prevents the behavior from being
attached to the sprite.
If the behavior contains no
on isOKToAttach
handler, then the behavior can be attached to any
sprite or frame.
This handler is called during the initial attachment of the behavior to the sprite or script channel
and also when attaching a new behavior to a sprite using the Behavior inspector.
Example
This statement checks the sprite type the behavior is being attached to and returns
TRUE
for any
graphic sprite except a shape and
FALSE
for the script channel:
-- Lingo syntax
on isOKToAttach me, aSpriteType, aSpriteNum
case aSpriteType of
#graphic: -- any graphic sprite type
return sprite(aSpriteNum).member.type <> #shape
-- works for everything but shape cast members
#script: --the frame script channel
return FALSE -- doesn't work as a frame script
end case
end
Summary of Contents for DIRECTOR MX 2004-DIRECTOR SCRIPTING
Page 1: ...DIRECTOR MX 2004 Director Scripting Reference...
Page 48: ...48 Chapter 2 Director Scripting Essentials...
Page 100: ...100 Chapter 4 Debugging Scripts in Director...
Page 118: ...118 Chapter 5 Director Core Objects...
Page 594: ...594 Chapter 12 Methods...
Page 684: ...684 Chapter 14 Properties See also DVD...
Page 702: ...702 Chapter 14 Properties See also face vertices vertices flat...
Page 856: ...856 Chapter 14 Properties JavaScript syntax sprite 15 member member 3 4...
Page 1102: ...1102 Chapter 14 Properties...