What didn't work? Sorry but I'm confused as to what code you've tried,
your recent handler still has the isOKToAttach arguments a bit wrong as
there _is_ a reference to the script member passed as the first
parameter. For example, I make this as a behavior (named "isOKToAttach
Test":
function isOKToAttach (aScript, aType, aSpriteNum) {
trace(aScript);
trace(aType);
trace(aSpriteNum);
}
When I drag that behavior over the stage then over a sprite, I see this
in the Message window:
// <(script "isOKToAttach Test")>
// #script
// 1
// <(script "isOKToAttach Test")>
// #graphic
// 1
So note that the first argument passed to the isOKToAttach function is
in fact a reference to the behavior script you're attempting to attach,
the second a reference to the sprite type and then third the sprite
number you are currently over (note the bogus spriteNum info for frame
scripts). If the docs fail to make that clear then that's another bug in
that section of the help (ugh), so regardless of the docs give that a
quick test and confirm/deny whether you see the same thing on your end.
Beyond that, I see one other problem (composed of two parts) in your
example code that is a JavaScript syntax issue: you cannot equate object
data types in JavaScript syntax and symbols are actually objects in
JavaScript syntax (unlike Lingo in which they are flat data). For
example, in the Message window:
-- using Lingo
x = #foo
y = #foo
put x=y
-- 1
// now in JavaScript syntax
x = symbol("foo");
y = symbol("foo");
trace(x==y);
// false
!! Bonk !! The problem is that x and y are _not_ equal here, they are
references to separate objects, sure those objects might be of the same
type and have the same property values, but the JavaScript syntax script
engine sees them as different in ==/!= operations. This is true across
the board in JavaScript syntax, it's just that symbols in particular
seem to bite folks more than others do, but keep in mind that you can't
compare any objects in JS syntax (vectors for example!). With objects
the way to check them for equality is to either (a) call a Lingo helper
function because Lingo auto-magically checks certain objects for
matching property sets, like vectors, rects, images, or (b) check each
property in the respective objects for equality. There's a third option
with symbols and that's to convert them to strings, keeping in mind case
sensitivity and the fact that when you convert a symbol to a string in
JavaScript syntax the "#" is included (x = symbol("test"); y =
x.toString(); trace(y); -- "#test").
Note: symbols, like strings and numbers are in fact auto-type converted
between Lingo and JavaScript syntax. This means your flat symbol data in
Lingo is auto-converted to a symbol object within JavaScript syntax, the
same is true in the reverse order in that the symbol object created in
JavaScript syntax is converted to flat symbol data within Lingo.
With all that in mind, your final isOKToAttach function should look like
this:
function isOKToAttach (aScript, aType, aSpriteNum) {
// check the type argument
switch (aType.toString()) {
case "#graphic": // sprite behavior attachment
// return true if not a shape cast member
return sprite(aSpriteNum).member.type.toString() != "#shape";
case "#script": // frame script attachment
// return false as frame script usage is not allowed
return false;
}
}
The above works on my end, it only allows attachment to non-QuickDraw
shape sprites.
Cheers,
Tom Higgins | Product Manager | Director & the Shockwave Player
Adobe Systems Incorporated
http://weblogs.macromedia.com/thiggins/
...
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi To post messages to the list, email
[email protected] (Problems, email [EMAIL PROTECTED]). Lingo-L is for
learning and helping with programming Lingo. Thanks!]