Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
Rolling a Ball.
Inside Macromedia Flash 5.0
Back Button - All In One
Print Dialog Behavior
cXtraGraphicIO
Image Magnify
Behavior Property Inspector
Help Studio 2000
Find angles of a right triangle
PrintOMatic
 

 

 

Behavior Easy Animation

Added on 6/7/1999

 

Compatibilities:
behavior D6_5 Mac PC

This item has not yet been rated

Author: DetlefBeyer

This behavior is used for simple and looping animations Detlef Beyer (d.beyer@hermes.de) A animation can contain a max of 99 members. Each member has to start with the same name and a two digit number for example: test01 to test23 or picture01 to picture09 The number has to start with 01

property pSprite      -- sprite channel
property pMax         -- last member
property pName        -- name of the members
property pAkt         -- actual member to display
property pDir         -- direction: 0 = A-Z, 1 = A-Z-A, 2 = Z-A-Z
property pLastTime    -- last animation
property pWait        -- time in ticks to wait between two animations

on beginSprite me
  set pSprite to the spriteNum of me
  set pName = the name of the member of sprite pSprite
  set pName = char 1 to length(pName) - 2 of pName
  set pLastTime = 0
  set pAkt = 0
  puppetSprite pSprite,TRUE
end beginSprite


on enterFrame me
  if the ticks > pLastTime + pWait then -- wait for pWait ticks
    case pDir of
      0 :
        -- A-Z
        if pAkt < pMax then
          set pAkt = pAkt + 1
        else
          set pAkt = 1
        end if
      1 :
        -- A-Z-A
        if pAkt < pMax then
          set pAkt = pAkt + 1
        else
          -- change direction
          set pDir = 2
        end if
      2 :
        -- Z-A-Z
        if pAkt > 1 then
          set pAkt = pAkt - 1
        else
          -- change direction
          set pDir = 1
        end if
    end case
    
    set pLastTime = the ticks
    set newName = pName & mMakeNull(pAkt,2)
    set the memberNum of sprite pSprite to the number of member newName
  end if
end enterFrame


on mMakeNull oldValue,noOfChars
  -- Get a n-digit string back
  set oldStr = string(oldValue)
  
  set newStr = oldStr
  
  if length(oldStr) < noOfChars then
    repeat with x = 1 to (noOfChars - length(oldStr))
      set newStr = "0" & newStr
    end repeat
  end if
  
  return newStr
end mMakeNull


on mKillPuppet me
  puppetSprite pSprite,false
end mKillPuppet

---

on getPropertyDescriptionList
  set p_list = [#pMax: [ #comment:"Last member:", #format:#integer, #default:10],
                                          #pDir: [ #comment:"Animtype (0,1,2):", #format:#integer, #default:0, #range:[#min:0,#max:2]],
                                          #pWait: [ #comment:"Wait for Ticks:", #format:#integer, #default:20]]
  
  return p_list  
end getPropertyDescriptionList


on getBehaviorDescription
  return "This behavior is used for simple and looping animations" & RETURN &
                            " Detlef Beyer (d.beyer@hermes.de)" & RETURN &  
                            "A animation can contain a max of 99 members. Each member" & RETURN &  
                            "has to start with the same name and a two digit number" & RETURN &  
                            "for example: test01 to test23 or picture01 to picture09" & RETURN &  
                            "The number has to start with 01"
end getBehaviorDescription

 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail