Ross Clutterbuck wrote:
>> My MP3 scripts rely on a field member being present in the cast. If there
>> are no field members present I would like to cancel the entire attachment
>> operation (similar to hitting cancel on a GPDL box).

Hi Ross,

Try adding the following property and handler to your behavior.

You'll need to customize the list of acceptable member types.  You may want
to adapt it so that it looks in the movie's cast(s) rather than on the
Stage, but the principle will be similar.

Cheers,

James


----------------------------------------------------------------------------

-- Author-time only property
property noFields

on isOKToAttach(me, aSpriteType, aSpriteNumber)
  -- Check if there are any field sprites on the Stage
  i = the lastChannel
  repeat while i
    if sprite(i).member.type = #field then
      exit repeat
    end if
    i = i - 1
  end repeat
  
  if i then
    -- There is at least one field sprite on the stage
    if aSpriteType = #graphic then
      case sprite(aSpriteNumber).member.type of
        #button, #bitmap: -- Add other appropriate member types here
          return TRUE -- sprite type is right, a field is available
      end case
    end if
    
  else if voidP(noFields) then
    -- There are no field sprites, and the user hasn't yet been warned
    tName  = string(me) -- "script ("Behavior name")"
    tName  = tName.char[9..tName.char.count - 1] -- ""Behavior name""
    alert = \
"BEHAVIOR USAGE WARNING"&RETURN&RETURN&\
"The behavior "&tName&" requires at least one field sprite on the Stage.
Please add one or more field sprites and try again."
    
    -- Remember not to show the warning again
    noFields = TRUE
  end if
  
  -- Sprite type may be wrong, or there may be no fields available
  return FALSE
end isOKToAttach

[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