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
Play/ Pause/ Stop/ Rewind a Flash Sprite
Set FrameRate of a Animated Gif Cast Member
Space Invaders
Find all occurances of a string in a Text member
Get and Set IDTag3 II of a mp3 file.
Sound FadeIn
Install Shield Pro
Handler Menu
DivXInstaller Xtra
Build to order Project
 

 

 

Behavior A char scroller

Added on 1/7/2003

 

Compatibilities:
D7 D8 D8_5

This item has not yet been rated

Author: BaZ

This behaviour function as a simple text scrollie, nothing more nothing less, I just found it usefull on ocassion.

property pSprite
property pMem

property pTextStr
property pTotalChar
property pCurrentChar
property pTickerState
property pRepeat
property pReverse

property pLastTime
property pDelayTime

on getPropertyDescriptionList me
  description = [:]
  addProp description,#pTextStr, [#default:"message", #format:#string, #comment:"The message to be shown..."]
  addProp description,#pDelayTime, [#default:25, #format:#integer, #comment:"The delay a next char will appear."]
  addProp description,#pRepeat, [#default:FALSE, #format:#boolean, #comment:"Repeat."]
  addProp description,#pReverse, [#default:FALSE, #format:#boolean, #comment:"Reverse."]
  return description
end

on getBehaviorDescription me
  return "Char Scrollie within a text or field member." & RETURN
  & "You can send an event to mEvent handler for a repeat by event call." & RETURN
  & "For example : sendSprite(10, #mEvent) or sendAllSprites(#mEvent) statements." & RETURN
  & "(C) 2003 by BaZ"
end

on beginSprite me
  -- Init vars
  pSprite = me.spriteNum
  pMem = sprite(pSprite).member
  member(pMem).wordWrap = TRUE
  -- Init time
  pLastTime = 0
  
  me.mReset()
end

on mReset me
  -- Prepare text box if reverse make spaces
  member(pMem).text = ""
  pTotalChar = pTextStr.char.count
  
  -- If reverse put spaces into it
  if pReverse then
    repeat with tNumChars = 1 to pTotalChar
      member(pMem).text = member(pMem).text & " "
    end repeat
  end if
  
  -- Prepare to be shown message
  pCurrentChar = 1
  
  pTickerState = #notDone
end

-- Call this handler if you want to repeat the effect when an event takes place.
-- sendSprite(x, #mEvent) of sendAllSprites(#mEvent)

on mEvent me
  -- If busy then nothing
  if not(pTickerState = #done) then exit
  -- Otherwise do a repeat accoring to event...
  me.mReset()
end

on exitFrame me
  if not(pTickerState = #done) then
    if not(the ticks < pLastTime + pDelayTime) then
      -- It' time to show a new char
      -- Check reverse
      if not(pReverse) then
        tNewChar = (pTextStr).char[pCurrentChar..pCurrentChar]
        member(pMem).text = member(pMem).text & tNewChar
      else
        tNewChar = (pTextStr).char[pCurrentChar..pCurrentChar]
        -- Erase a space and replace it with a char unless if it's the last char to be used
        if not(pTotalChar = pCurrentChar) then
          delete member(pMem).char[(pTotalChar - pCurrentChar)]
        end if
        member(pMem).text = member(pMem).text & tNewChar
      end if
      
      if pCurrentChar = pTotalChar then
        pTickerState = #done
      else
        pCurrentChar = pCurrentChar + 1
      end if
      
      -- Record time for next update
      pLastTime = the ticks
      
    end if
  else
    -- If done check for repeat the thing...
    if pRepeat then
      -- Gotta reset my stuff
      me.mReset()
    end if
  end if
end

 


Contact

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

Send e-mail