Hi Craig,
I just saw this thread and was surprised you had problems with the
scriptInstanceList. I was sure I'd played this in the past so I just set up a little
test
movie and it seems to work for me.
I put this on a sprite in channel 1
property pNum
on mouseDown me
alert pNum & me
end
on setNum me, aNum
pNum = aNum
end
on getPropertyDescriptionList me
pdl = [:]
pdl[#pNum] = [#comment : "number", #default:0, #format:#integer]
return pdl
end
then on another sprite I put
property pCounter
property pSL
on mouseDown me
pCounter = pCounter + 1
if pCounter mod 2 then
pSL = sprite(1).scriptInstanceList
sprite(1).setNum(random(100))
sprite(1).scriptInstanceList = []
else
sprite(1).scriptInstanceList = pSL
end if
end
click on sprite 1 to get it to alert the info
click on the other sprite once to remove the behaviour on sprite(1), but first it
randomly defines a new value for the pNum property of sprite(1)
click on sprite 1, no alert
click on the other sprite to restore the functionality of sprite 1
click on sprite 1 and see functionality restored with a new value written to pNum.
hth,
Rob
10/09/2003 9:18:27 PM, "Craig Taylor" <[EMAIL PROTECTED]> wrote:
>> Craig,
>>
>> Yes, I would use a completely different approach than mucking with
>> the scriptInstanceList. If you have written your own behavior that
>> handles clicking on each answer, and you have a way of talking to all
>> answer sprites, then here's what I would do.
>>
>> In the answer behavior, add a property called something like,
>> pAvailable. When the user can answer the question, pAvailable should
>> be set to TRUE. When the user selects one answer, you should call a
>> handler in the behavior attached to all answers that sets pAvailable
>> to FALSE
>
>Irv,
>
>I originally considered using a flag to turn user interaction on and off,
>but unfortunately, given the rest of the functions (that I haven't
>outlined), it does get a little messy. Having said that, I am going to
>rewrite it in a very similar manner to what you proposed. Thanks for the
>input.
>
>Couple of things to note about why using the scriptInstanceList didn't work
>for me. Just curious if anyone has encountered similar findings.
>
>When I created a script as such:
>script1 = script("myScript").new("right","wrong")
>sprite(x).scriptInstanceList.add(script1)
>
>It seemed to ignore the parameters that I fed it. When it ripped through
>the code AFTER clearing the scriptInstanceList and then reapplying
>behaviours, it couldn't find these values anymore. (They were initiated
>with a getPropertyDescriptionList on the original behaviour).
>
>Also, I had a rollover behaviour that was based on:
>sprite(me.spriteNum).member = x
>
>Again, once I stripped behaviours from the sprite and then reapplied them, I
>got an error on mouseEnter. If I changed the code to this:
>sprite(the currentSpriteNum).member = x
>
>It worked! Unfortunately, too many "me" references down the line to make
>this a feasible fix. Is it just getting confused between the initial
>instance of the behaviour and the reapplied instance?? Got me. Thoughts?
>
>Thanks also to Andr�e and Howdy for their responses. And Irv, kudos on the
>e-book. Great OOP reference!
>
>
[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!]