James Newton wrote:


> Hi Rodrigo,
> 
> It sounds as if you are talking about a viewport.  You can do this with a
> Linked Director Movie.  You'll find an example which uses scrollbars at:
> 
> <http://www.duguk.org/articles/LDM_003/LDMScroll.zip>
> <http://www.duguk.org/articles/LDM_003/LDMScroll.sit>
> 

Hey James,

It looks like you and I are playing in the same sandbox :-)

I had a quick look at your viewport code, nice stuff. I'm also using a 
similar approach to yours of keeping a property description list tucked 
inside of an LDM and using a generic behaviour to extract it and make 
modifications. I thought I'd pass along I tip to help out with your 
mGetInitializers handlers which extracts a property list from the 
sprite's scriptList. This approach should eliminate all three of your 
failure cases

on mGetInitializers(me, aSpriteNumber, aBehaviorMember) --------------
<snip>
   -- This may fail to provide the correct information in three cases:
   -- 1. If two instances of the same behavior are attached to this
   --    sprite.
   -- 2. If two different behaviors with the same name are attached to
   --    the same sprite, since <aBehaviorMember> is determined from
   --    the name of the script.
   -- 3. If another member with the same name as this behavior appears
   --    in a lower-numbered castLib slot.
   --
   -- NOTE: This data is collected in this host movie behavior and
   -- passed to the behavior scripts in the Linked Movie.  If the
   -- Linked Movie tried to determine this data for itself, Director
   -- would manage to create the list, but would then crash.
   --------------------------------------------------------------------
   </snip>

The code I use is as follows (watch out for line wraps)

on getPropertyDescriptionList me
   if the currentSpriteNum>0 then
     sList=sprite(the currentSpriteNum).scriptList

     --    if not(sList=[]) then
     counter=sList.count
     instances=0
     repeat with i = 1 to counter
       if me=sList[i][1].script.validate() then
         iAm=i
         instances=instances+1
       end if
     end repeat
     if instances>1 then
       alert "There are too many instances 
of"&&me&","&&sList[iAm][1]&","&&"attached to sprite"&&the 
currentSpriteNum&". Please ensure only one copy is attached."
       return
     end if

     --iAm will be > 0 if this is not the initial application of the 
behaviour
     if iAm>0 then
       propList=value(sList[iAm][2])
       if propList=0 then
         propList=[:]
       end if
     else
       propList=[:]
     end if

-- at this point I now have a valid propertyList to work with and can 
send it off to the LDM and work with it as needed.

   end if
end

on validate me
   return me
end


Let me know if this works for you or if you find any holes in it.

later,

Rob

[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!]

Reply via email to