Am 10.05.2006 um 15:04 schrieb Michael Nadel:
Hey guys,
I've been following the spheroid distortion discussion with
interest, but I don't know much about parent scripts. How do I
actually make this code work? Do I atatch it to a picture as a
parent script? How do I activate it? Do I write :
on mouseDown
spherize (sprite(me.spritenum).member)
end
?? Confused,
with your syntax it would need to be a moviescript.
while there is no reason it couldn't be a movie script (just search
for and remove the "me"s in the parameters of the handlernames and in
the handlercalls themselves), I like parentscripts myself much more,
as they are encapsulated entities, which not only are faster to
access, but also easier to re-use in other context (the benefit of
encapsulation)
to use it as a parentscript, make a script member with the scripttext
you found in the email, name it as you like (in this case for example
"spherizeFilter" and set the scripttype of this scriptmember to
#parent (either in the "script" tab of the PI or with this line of
lingo: member("spherizeFilter").scripttype = #parent)
now to use it you create an instance of the script -> a scriptobject
with:
mySpherizeFilter = new(script "spherizeFilter")
and then use it:
mySpherizeFilter.spherize(sprite(me.spritenum).member.image)
it takes an image object and not a member reference like in your
example!
to speed up performance you should work on a copy of the members
image, which is MUCH FASTER!
and if you plan to use the parent script more than just a few times,
save the scriptinstance for later reuse, as creating a scriptinstance
also takes some cycles...
so if you make a behavior do the following:
property pSpherizeFilter
on mouseDown me
if ilk(pSpherizeFilter) <> #instance then pSpherizeFilter = new
(script "spherizeFilter")
i = sprite(me.spritenum).member.image.duplicate()
pSpherizeFilter.spherize(i)
sprite(me.spritenum).member.image = i
end
-- and since we want to leave all tidy as it was before we put our
dirty fingers on it:
property pSavedImage
on beginsprite me
pSavedImage = sprite(me.spritenum).member.image.duplicate()
end
on endSprite me
sprite(me.spritenum).member.image = pSavedImage
end
---------------------------
|||
a¿ex
[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!]