> while we�re on this subject, what handler should be executed when an > instance of a script is added to a sprite scriptinstancelist? the on > beginsprite doesn�t seem to be executed, so that�s why i have to send > sprites messages. and even those seem not work sometimes.
You have probably already seen James' and my latest posts, but I'll expand a bit (been doing that for the last 30 years, actually). As James says, you don't have to have an "on new" handler. It's implicit. However, if you have an "on new" handler, you can pass parameters to it when you create the instance. E.g., in your script named "setPos": property pCurrentVal property pXPos property pYPos on new me, xPos, yPos, startVal pXPos = xPos pYPos = yPos pCurrentVal = startVal return me End on beginSprite me sprite(me.spriteNum).locH = pXPos sprite(me.spriteNum).locY = pYPos end Then, when you create the instance, pass the values you want for xPos, yPos, and startVal. New() will always execute before beginSprite, even for sprites you manually attach (that is, without setting the scriptInstanceList). The important concept here is instances. When you create the new instance, Director does, as you noted, set aside some memory for that instance. That memory includes the properties for that particular instance. Ten instances, ten sets of properties, each unique to the instance. There is, however, only one copy of the executable code, shared by all instances. If you think about it, it makes perfect sense. Code acts on data, and it acts the same no matter what the data (well, within limits). So, an object really only needs to keep track of its own data--properties and local vars. Hope this helps. Cordially, Kerry Thompson [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!]
