Yes.. sprite(1) need not exist before you run this script..
this is a true dynamic method to create sprites at runtime. Only the catch
is in the "puppet" property, which has to be set to true, else the sprite
won't be visible.
I too have been using this method for long and have'nt yet faced any
problems. Infact I think this is the most powerful feature that director
support, which can be used to write effective and true object oriented
programming. Unfotunately a clear explanation for this procedure is not
given in Director help.
The generic code would be somewhat like this:
-- this handler puts the sprite on the stage
on putSprite
pnSpriteNum = getChannelNum() -- get the empty channel
sprite(pnSpriteNum).puppet = TRUE
sprite(pnSpriteNum).member = psInitMember
sprite(pnSpriteNum).ink = 36
end
-- this handler gets the empty channel to place the runtime sprite
on getChannelNum
repeat with lni = 1 to 1000 -- this loop starts searching for empty
channels from 1 to 1000
if sprite(lni).member.memberNum = 0 then
return lni
end if
end repeat
alert "OUT OF CHANNELS"
end
To delete the sprite:
-- this handler is used to delete the object
-- this handler is invoked when the movie goes to next screen
on deleteObject me
gnCount = gnCount - 1
sprite(me.pnSpriteNum).member = member(0,0)
sprite(me.pnSpriteNum).scriptInstanceList = []
sprite(me.pnSpriteNum).puppet = FALSE
end
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
Behalf Of Charlie Fiskeaux II
Sent: Tuesday, September 25, 2001 3:27 AM
To: [EMAIL PROTECTED]
Subject: Re: <lingo-l> from cast to stage
Does sprite(1) not exist before you run this script?
Charlie Fiskeaux II
The Creative Group
www.cre8tivegroup.com
859/858-9054 x29
cell: 859/312-3883
<code>
on beginsprite me
sprite(1).visible = true
sprite(1).type = 36 --bitmap type
sprite(1).ink = 36 --background transparent
sprite(1).backColor = 0
sprite(1).moveableSprite = false
sprite(1).foreColor = 255
sprite(1).member = member("picture 1")
sprite(1).puppet = true
sprite(1).trails = false
sprite(1).blend = 100
sprite(1).loc = point(320,240)
end
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/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!]