Try it and see - no reason it wouldn't work if implemented correctly.
Before creating this post I had tried by adding it to scriptInstanceList right before (the line above) creating the child object of the graphic that must play the effect (and adding the "behavior" parameters list for the behavior), it didnt work, I tried it then adding it after the child object is created and it didnt work either. Tried with scriptList doing the same 2 things and didnt work. So I think the only thing left to try before canibalazing the script (sounds fun ) is try the on runPropertyDialog thingy that is supposed to override the parameters defined by onGetPropertyDescriptionList. Will post results!
1 person found this helpful
You need to write a constructor - a "new" handler - to initialize the properties that are specified in the getPropertyDescriptionList handler. Also set the property SpriteNum. Then after calling new you call beginSprite. That should make it work. Forget about the ScriptList stuff. That is for score control.
Thank you for the input, will try that for sure! Just to clarify, if I'm understanding you correctly I need to treat it as a child object for the first part of it (but excluding adding it to the scriptInstanceList since probably it's not suited for the situation as it's not a child object or parent script instance what we are dealing with actually but a behavior instance). Call the new handler created (within a copy of the pixelate behavior I asume) and then call beginSprite of the "pixelate" behavior. Is that what you meant?
1 person found this helpful
The differences between Parent, Movie, and Behavior scripts is very minor; Important, but minor.
You can call "new" on any type of script and an object instance will be returned. All scripts have an implicit new handler for constructing instances of scripts.
When you call "new" on a behavior you are doing the same thing Director does when it encounters a new sprite in the score that has a behavior attached. Director instantiates an instance and then assigns values to the instance properties that are listed in the scriptList. Since you are instantiating the behavior script through code, it is up to you to initialize the properties.
It's important to remember that when an instance of a behavior is added to a sprite's scriptInstanceList, the sprite inherits all the properties and handlers of that instance.
What I would do is copy the "Pixelate" code to a new behavior script and make your modifications there. You could also use inheritance via the ancestor property if you would like to up the challenge.
Then the pseudo code would be something like:
sprite(1).puppet = true
sprite(1).member = member("Foo")
sprite(1).scriptInstanceList.add(script("Pixelate").new(1, Arg2, Arg3, Arg4))
If that is not clear, ask some more questions.
Thanks for the extended explanations! This is an experiment I'm making on how to incorporate this kind of behaviors dinamically on runtime and in the current state of my project as you will figure is not the top priority untill some other basic stuff in the program gets 100% straightened out (that may take a morning or a couple of days you know). That doesnt mean it's not important, in the contrary. So to be brief, I'm gonna try all that's left to try with the "pixelate" behavior these next few days and will come back with the results. I just wanted to thank you for your participation for now and not let you think I wasnt reading your post
This is how I have made it to work, finally I think it's necesary to add it to the scriptInstanceList of the same sprite or else (in my testings) won't work. Thanks again! property values can be altered in the new handler but keeping in mind the limits established by the designers for these parameters (check on getPropertyDescriptionList for this).
- Calling code from outside:
- RIGHT AFTER CREATING THE INSTANCE OF THE GRAPHIC:
_pixelate= new(script"customPixelate", theGraphicSpNum)
- Inside a custom version of pixelate:
property appearWhen, pixelateDuration, horizontalPixels, verticalPixels, minimumDim
on new me, aSpNum -- for implementation via lingo
appearWhen = "beginning of sprite"
pixelateDuration = 50
horizontalPixels = 3
verticalPixels = 3
minimumDim = 4
Just for your reference the original behavior is under window/library palette and then animation/sprite transitions/pixelate