25/06/2003 8:59:02 AM, Quixadá <[EMAIL PROTECTED]> wrote: >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. >q >
Hey Quixada, Glad you got your scriptInstance issue worked out. Below is the script I use for dynamic sprite creation. It allows me to create a sprite, assign properties like member, ink etc and as many behaviours as I want, all in one call. Also it is designed to use "standard" behaviour structure, that is you don't have to do anything special to behaviours you want to attach to dynamic sprites. You'll see that it forceably calls the beginSprite handler to make sure the scripts are properly initialized. Also there is code to deal with the endSprite handler. If you want to see it in action along with a demonstration of the pitfalls of dynamic sprites (this is what Kerry mentioned earlier) (and a crude partial work around for the problem) then check out http://www.manibus.com/testzone/dynamicSprite/dynaSprite.dir hth Rob PS if working with dynamic sprites the only real solution for them not interfering with score authored sprites is to dedicate a range of channels for them and never put score authored sprites in those channels --dynamic sprite generation --written by Rob Romanek, [EMAIL PROTECTED] on makeSprite aNum, aProps, aBhvrs --check for valid aNum, the sprite number if not(integerP(aNum)) then return if aNum<1 and aNum>the lastchannel then return me = script("dynamicSprite") puppetSprite aNum, 1 --aProps list passed in as defaultProps = [\ #member:member(-1),\ #loc: point(0,0),\ #ink: 0,\ #blend: 100,\ #color: rgb(0,0,0),\ #backColor: 0\ ] --change default props to those passed in c=defaultProps.count repeat with i = 1 to c tProp = defaultProps.getPropAt(i) tValue = aProps[tProp] if not(voidP(tValue)) then aProps.deleteProp(tProp) defaultProps[i] = tValue end if end repeat --add additional props c = aProps.count repeat with i = 1 to c tProp = aProps.getPropAt(i) tValue = aProps[i] defaultProps[tProp]=tValue end repeat --apply them to the sprite c = defaultProps.count repeat with i = 1 to c tProp = defaultProps.getPropAt(i) tValue = defaultProps[i] case tProp of #member: sprite(aNum).member = tValue #loc: sprite(aNum).loc = tValue #ink: sprite(aNum).ink = tValue #blend: sprite(aNum).blend = tValue #color: sprite(aNum).color = tValue #backColor: sprite(aNum).backColor = tValue #rect: sprite(aNum).rect = tValue #rotation: sprite(aNum).rotation = tValue otherwise do "sprite(" & aNum & ")." & tProp & "=" & tValue end case end repeat if voidP(aBhvrs) then return sprite(aNum).scriptInstanceList = [me.new()] c = aBhvrs.count repeat with i = 1 to c tProp = aBhvrs.getPropAt(i) tValue = aBhvrs[i] sprite(aNum).scriptInstanceList.add(script(tProp).new()) tvc = tValue.count if tvc then si = sprite(aNum).scriptInstanceList.count repeat with j = 1 to tvc tProp2 = tValue.getPropAt(j) tValue2 = tValue[j] sprite(aNum).scriptInstanceList[si][tProp2]=tValue2 end repeat end if end repeat sendSprite(aNum, #beginSprite) end on endDynamicSprite me if voidP(me) then return if not(objectP(me)) then return sprite(me.spriteNum).memberNum = -1 sendSprite(me.spriteNum, #endSprite) sprite(me.spriteNum).puppet = 0 sprite(me.spriteNum).scriptInstanceList = [] end [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!]