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
DirectTransition3D Xtra, Set III
cXtraInfo
Streaming Media
Rotate-a-Sprite
Director 6.5 Stubs
Toggle ButtonsEnabled Property of a Flash Sprite
ADOXtra
Beatnik Xtra
simSock Xtra
StartFramesScript
 

 

 

Behavior Final text box resizer for text members

Added on 10/4/2001

 

Compatibilities:
behavior D7 D8 D8_5 Mac PC Shockwave

This item has not yet been rated

Author: psychicparrot (website)

Resizes the width and height of a text members bounding box. Faster and smoother than before. Final version. I promise.

-- Dynamic bounding text box adjustment behaviour v3final
--
-- By Jeff Murray March 14th 2001 / v2 July 12th 2001 / v3 October 4th 2001
--
-- http://www.psychicparrot.com
--
--
-- just drop this behaviour onto a text sprite that you want to resize dynamically and change the
-- TargetMem variable (make a bitmap cast member - just a single pixel will do - then use the
-- member number of your new bitmap i.e. set targetmem to equal your new bitmap member.)

-- to use : sendallsprites(#setwidth)

property maxx,mycolor,sourceMem
property sourceImage,imageWidth,imageHeight1
property imageHeight,sourceColor
property spritenum
global ed,eobj,gzfactor

on beginSprite me
  
  sprite(spritenum).member.boxtype = #fixed
  sprite(spritenum).member.alignment = #left
  
end beginSprite

on setWidth me
  
  -- set up variable default values  
  
  maxx = 0
  sourceMem = sprite(spritenum).member
  TargetMem = 6 -- temporary bitmap member for processing the bitmap
  
  -- size up text box to allow for expanding as well as cropping
  
  sourceMem.width = 1760
  
  -- get parameters for new member
  
  sourceImage = member(sourceMem).image
  imageWidth = sourceImage.width
  imageHeight = sourceImage.height
  sourceRect = sourceImage.rect
  destRect = sourceImage.rect
  
  -- turn that damn wordwrap off!
  
  member(sourceMem).wordwrap= FALSE
  
  -- copyPixels bit to copy text member into a bitmap member  
  
  newImage = image(imageWidth,imageHeight,1,0)
  (newImage).copyPixels(sourceImage, destRect, sourceRect)
  member(targetMem).image = newImage
  member(targetMem).regPoint = point(0,0)
  workingImage = member(targetmem).image.duplicate()  
  workingImage = workingImage.trimWhiteSpace()
  imageWidth = workingImage.width
  
  -- set the original text box to the new value discovered above.  
  
  sprite(spritenum).member.width = imageWidth + 5
  
  -- set the height to take the top space out
  
  sprite(spritenum).member.fixedLineSpace = sprite(spritenum).member.fontsize
  
end

 


Contact

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

Send e-mail