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
XTRA dmmXSC - a client for XML Socket Server
Tygtris
Open Recordset
convert to upper or to lowercase
Download Net Thing
Progress Bar
ZGTSB-Shape Or Vector Shape Slider Scroll
Printing Acrobat files with Buddy API
SaveScripts Xtra
Standard 3 state button
 

 

 

Behavior Outline Text

Added on 7/1/2006

 

Compatibilities:
behavior D8 D8_5 D9 Mac PC Script

This item has not yet been rated

Author: Chunick (website)

Here's one method to outline and dropshadow text... of course, if you have DMX 2004 and the new Flash Xtra then it would be a heck of a lot quicker and less code to do it... plus, it'd do a nicer job... but if you don't, then this may interest you. Suggestions on optimizatins or additions welcome.


-- Outline and Dropshadow Text
-- (c) 2006 by Josh Chunick
-- please keep comments intact,
-- otherwise use how you like

-- place script in a moviescript
-- Parameters:
-- input - this can be a text member or a property list.
-- if you use a property list then the format looks like this:
-- [[property list], string] where the p property list is a list of text formatting properties in this format:
-- eg. [[#font: "Arial", #fontSize: 24, #fontStyle: [#bold], #alignment: #center, #charSpacing 5], "This is my outline text."]
-- lnSize - the size of the outline as an integer value. Not too useful beyond 2 or 3.
-- knockout - boolean. Set to true to make the original text area transparent.
-- insideColor - colour of text.
-- outsideColor - colour of outline and dropshadow.
-- dsDirection - integer - four possible values corresponding to the direction of the shadow.
-- 1: top,left 2: top,right 3: bottom, right 4: bottom, left.
-- dsAmount - integer - the amount of offset of the dropshadow.


on outlineText (input, lnSize, knockout, insideColor, outsideColor, dsDirection, dsAmount)

newMem = new(#text)
newMem.boxType = #fixed
newMem.topSpacing = 0
newMem.leftIndent = 0
Case input.ilk() of
#member:
newMem.media = input.media
#list:
newMem.wordWrap = False
if input[1].getAProp(#font) <> VOID then
newMem.font = input[1][#font]
else
newMem.font = "Arial"
end if
if input[1].getAProp(#fontSize) <> VOID then
newMem.fontSize = input[1][#fontSize]
else
newMem.fontSize = 14
end if
if input[1].getAProp(#fontStyle) <> VOID then
newMem.fontStyle = input[1][#fontStyle]
else
newMem.fontStyle = [#plain]
end if
if input[1].getAProp(#alignment) <> VOID then
newMem.alignment = input[1][#alignment]
else
newMem.alignment = #left
end if
if input[1].getAProp(#fixedLineSpace) <> VOID then
newMem.fixedLineSpace = input[1][#fixedLineSpace]
end if
if input[1].getAProp(#charSpacing) <> VOID then
newMem.charSpacing = input[1][#charSpacing]
end if
if input[1].getAProp(#antiAlias) <> VOID then
newMem.antiAlias = input[1][#antiAlias]
end if
if input[1].getAProp(#antiAliasThreshold) <> VOID then
newMem.antiAliasThreshold = input[1][#antiAliasThreshold]
end if
if input[1].getAProp(#kerning) <> VOID then
newMem.kerning = input[1][#kerning]
end if
if input[1].getAProp(#kerningThreshold) <> VOID then
newMem.kerningThreshold = input[1][#kerningThreshold]
end if

newMem.text = input[2]
lnCount = newMem.line.count
newW = 0
repeat with i = 1 to lnCount
if newMem.charPosToLoc(newMem.line[1..i].char.count) > newW then
newW = newMem.charPosToLoc(newMem.line[1..i].char.count + 1)[1]
end if
end repeat
newMem.width = newW
End Case

newMem.width = newMem.width

if voidP(lnSize) then lnSize = 1
if voidP(knockout) then knockout = 0
if voidP(insideColor) then insideColor = newMem.color
if voidP(outsideColor) then outsideColor = newMem.color
if voidP(dsDirection) then dsDirection = 0
if voidP(dsAmount) then
dsAmount = 1
if voidP(dsDirection) then dsAmount = 0
end if

newMem.leftIndent = lnSize
newMem.topSpacing = lnSize
newMem.height = newMem.height + lnSize
newMem.width = newMem.width + lnSize

if Not(voidP(dsDirection)) then
-- 1: top,left 2: top,right 3: bottom,right 4: bottom,left
Case dsDirection of
1:
newMem.leftIndent = dsAmount + lnSize
newMem.width = newMem.width + dsAmount + lnSize + 1
newMem.topSpacing = dsAmount + lnSize
newMem.height = newMem.height + lnSize
2:
newMem.rightIndent = dsAmount + lnSize
newMem.width = newMem.width + dsAmount + lnSize + 1
newMem.topSpacing = dsAmount + lnSize
newMem.height = newMem.height + lnSize
3:
newMem.rightIndent = dsAmount + lnSize
newMem.width = newMem.width + dsAmount + lnSize + 1
newMem.height = newMem.height + dsAmount + lnSize
4:
newMem.leftIndent = dsAmount + lnSize
newMem.width = newMem.width + dsAmount + lnSize + 1
newMem.height = newMem.height + dsAmount + lnSize
End Case
end if

newMem.color = rgb(0,0,0)
aImg = image(newMem.width, newMem.height, 8, #grayscale)
aImg.copyPixels(newMem.image, aImg.rect, aImg.rect)

alphaImg = aImg.duplicate()
alphaImg.copyPixels(newMem.image, newMem.rect + rect(lnSize,0,lnSize,0), newMem.rect, [#maskImage: aImg])
alphaImg.copyPixels(newMem.image, newMem.rect + rect(lnSize,lnSize,lnSize,lnSize), newMem.rect, [#maskImage: aImg])
alphaImg.copyPixels(newMem.image, newMem.rect + rect(0,lnSize,0,lnSize), newMem.rect, [#maskImage: aImg])
alphaImg.copyPixels(newMem.image, newMem.rect + rect(-lnSize,lnSize,-lnSize,lnSize), newMem.rect, [#maskImage: aImg])
alphaImg.copyPixels(newMem.image, newMem.rect + rect(-lnSize,0,-lnSize,0), newMem.rect, [#maskImage: aImg])
alphaImg.copyPixels(newMem.image, newMem.rect + rect(-lnSize,-lnSize,-lnSize,-lnSize), newMem.rect, [#maskImage: aImg])
alphaImg.copyPixels(newMem.image, newMem.rect + rect(0,-lnSize,0,-lnSize), newMem.rect, [#maskImage: aImg])
alphaImg.copyPixels(newMem.image, newMem.rect + rect(lnSize,-lnSize,lnSize,-lnSize), newMem.rect, [#maskImage: aImg])

newMem.color = outsideColor
memImg = image(newMem.width, newMem.height, 32)
memImg.copyPixels(newMem.image, newMem.rect + rect(lnSize,0,lnSize,0), newMem.rect,[#ink: 39, #maskImage: aImg])
memImg.copyPixels(newMem.image, newMem.rect + rect(lnSize,lnSize,lnSize,lnSize), newMem.rect,[#ink: 39, #maskImage: aImg])
memImg.copyPixels(newMem.image, newMem.rect + rect(0,lnSize,0,lnSize), newMem.rect,[#ink: 39, #maskImage: aImg])
memImg.copyPixels(newMem.image, newMem.rect + rect(-lnSize,lnSize,-lnSize,lnSize), newMem.rect,[#ink: 39, #maskImage: aImg])
memImg.copyPixels(newMem.image, newMem.rect + rect(-lnSize,0,-lnSize,0), newMem.rect,[#ink: 39, #maskImage: aImg])
memImg.copyPixels(newMem.image, newMem.rect + rect(-lnSize,-lnSize,-lnSize,-lnSize), newMem.rect,[#ink: 39, #maskImage: aImg])
memImg.copyPixels(newMem.image, newMem.rect + rect(0,-lnSize,0,-lnSize), newMem.rect,[#ink: 39, #maskImage: aImg])
memImg.copyPixels(newMem.image, newMem.rect + rect(lnSize,-lnSize,lnSize,-lnSize), newMem.rect,[#ink: 39, #maskImage: aImg])

if Not(voidP(dsDirection)) then
-- 1: top,left 2: top,right 3: bottom,right 4: bottom,left
Case dsDirection of
1:
rectMod = rect(-dsAmount,-dsAmount,-dsAmount,-dsAmount)
2:
rectMod = rect(dsAmount,-dsAmount,dsAmount,-dsAmount)
3:
rectMod = rect(dsAmount,dsAmount,dsAmount,dsAmount)
4:
rectMod = rect(-dsAmount,dsAmount,-dsAmount,dsAmount)
End Case
alphaImg.copyPixels(alphaImg,(newMem.rect + rectMod), (newMem.rect),[#ink: 39, #maskImage: alphaImg])
memImg.copyPixels(memImg,(newMem.rect + rectMod), (newMem.rect),[#ink: 39, #maskImage: alphaImg])
end if

if knockout then
newMem.color = rgb(255,255,255)
alphaImg.copyPixels(newMem.image, newMem.rect, newMem.rect)
else
newMem.color = insideColor
memImg.copyPixels(newMem.image, newMem.rect, newMem.rect)
end if

memImg.useAlpha = true
memImg.setAlpha(alphaImg)
memImg = memImg.trimWhiteSpace()
if the runMode = "Author" then newMem.erase()

return memImg

end

 


Contact

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

Send e-mail