--*************************************************************************
-- Script: PRINT_CLASS
-- @Version 0.2
-- @Author Valentin Schmidt
-- @Created 19.06.2009
-- @Modified 22.07.2009
--
-- @Description
-- This script implements printing based on flash.
--
-- Usage:
-- p = script("PRINT_CLASS").new()
-- p.mAddPage()
-- p.mAddText("Hello World!", 50, 50, 100)
-- p.mPrint()
-- p.mDestroy()
-- p=0
--
-- @Dependencies
-- # (empty) flash 8 sprite with scaleMode=#noScale
--
-- @History
--
-- v0.1
-- First version
--
-- v0.2
-- minor bug fix
--
--**************************************************************************
-- public
property pPageCnt
property pCurrentPageNum
-- internal
property pFlashSprite
property pPageFormat
property pPrintArea
property pMcCnt
property pCurrentPage
property pPrintAsBitmap
property pBitmaps
-- settings
property pFillColor
property pFillAlpha
--property pFillStyle ???
property pTextFormat
property pLineStyle
property pAutoPageBreak
property pMargins
property pBreakChars
----------------------------------------
-- Constructor
-- @param sprite tFlashSprite: a flash sprite reference (flash 8 movie, can be empty)
-- @param list|string tPageFormat: (optional) either a list [widthInPt, heightInPt] or one of the following strings: "A3", "A4"(=default), "A5", "letter", "legal"
-- @param string tOrientation: (optional) "L" for landscape or "P" for portrait (=default)
----------------------------------------
on new (me,tFlashSprite, tPageFormat, tOrientation)
pFlashSprite = tFlashSprite
if not listP(tPageFormat) then tPageFormat = "A4"
case (tPageFormat) of
"A3":
tPageFormat=[842.0, 1191.0] -- 841.89, 1190.55
"A4":
tPageFormat=[595.0, 842.0] -- 595.28, 841.89
"A5":
tPageFormat=[421.0, 595.0] -- 420.94, 595.28
"letter":
tPageFormat=[612.0, 792.0]
"legal":
tPageFormat=[612.0, 1008.0]
end case
if tOrientation="L" then
pPageFormat = [tPageFormat[2], tPageFormat[1]] -- Landscape
else
pPageFormat = tPageFormat -- default: Portrait
end if
pPrintArea = pFlashSprite.newObject("Object")
pPrintArea.xMin = 0
pPrintArea.xMax = pPageFormat[1]
pPrintArea.yMin = 0
pPrintArea.yMax = pPageFormat[2]
-- TEXT
pTextFormat = [:]
pTextFormat["color"] = "0x000000"
pTextFormat["font"] = "Arial"
pTextFormat["size"] = 11
-- FILL
pFillColor = "0x000000"
pFillAlpha = 100
-- DRAW
pLineStyle = [:]
pLineStyle["thickness"] = 1
pLineStyle["rgb"] = "0x000000"
pLineStyle["alpha"] = 100
pLineStyle["pixelHinting"] = 0
pLineStyle["noScale"] = "normal"
pLineStyle["capsStyle"] = "round"
pLineStyle["jointStyle"] = "round"
pLineStyle["miterLimit"] = 3
-- AUTO PAGE BREAK
pAutoPageBreak = 0
pBreakChars = [SPACE, "-", ".", ",",";"]
-- internal
pPageCnt = 0
pCurrentPageNum = 0
pCurrentPage = VOID
pBitmaps = []
pMcCnt = 0
pPrintAsBitmap = []
pMargins = [#left: 28, #top: 28, #right:28, #bottom:28] -- 28 pt = 2 cm
return me
end
----------------------------------------
-- Safely deletes object, releases memory
----------------------------------------
on mDestroy (me)
cnt = count(pBitmaps)
repeat with i = cnt down to 1
pBitmaps[i].dispose() -- ???
pBitmaps.deleteAt(i)
end repeat
repeat with i = 1 to pPageCnt
pFlashSprite["page"&i].clear() -- ???
pFlashSprite["page"&i].removeMovieClip()
end repeat
pPageCnt = 0
pCurrentPageNum = 0
end
--**************************************
-- PUBLIC
--**************************************
----------------------------------------
-- Sets page margins
-- @param propList tMargins: propList containing one or more of the following properties: #left, #right, #top, #bottom
-- margins are specified as floats
----------------------------------------
on mSetMargins (me, tMargins)
cnt = tMargins.count
repeat with i = 1 to cnt
pMargins[tMargins.getPropAt(i)] = tMargins[i]
end repeat
end
----------------------------------------
-- (De)Activates autoPageBreak
-- @param integer tBool
----------------------------------------
on mSetAutoPageBreak (me, tBool)
pAutoPageBreak = tBool
end
----------------------------------------
-- Adds a new page to the document
----------------------------------------
on mAddPage (me)
pPageCnt = pPageCnt + 1
pCurrentPage = pFlashSprite.createEmptyMovieClip("page"&pPageCnt, pFlashSprite.getNextHighestDepth())
pCurrentPageNum = pPageCnt
me.mHeader()
me.mFooter()
end
----------------------------------------
-- Changes the active page
-- @param integer tPageNum
----------------------------------------
on mSetActivePage (me, tPageNum)
pCurrentPage = pFlashSprite["page"&tPageNum]
pCurrentPageNum = tPageNum
end
----------------------------------------
-- Adds a text to the document at the specified position
-- @param string tText: can be plain text or html. To use html, pass ["html":1, ....] as tSettings parameter. See {@link html.htm} for supported HTML tags.
-- @param integer tX
-- @param integer tY
-- @param integer tW
-- @param integer tH: (optional)
-- @param propList tSettings: (optional) propList of setting-values. See {@link settings.htm settings.htm} for a list of supported values.
-- @param propList|string tFormat: (optional) propList of setting-values or a CSS string. See {@link format.htm format.htm} and {@link css.htm css.htm} for lists of supported values.
--
-- @return float y-position of text bottom
----------------------------------------
on mAddText (me, tText, tX, tY, tW, tH, tSettings, tFormat)
if voidP(tSettings) then tSettings=[:]
if voidP(tH) or tH=0 then tH=pPageFormat[2]
mc = pCurrentPage.createTextField(me._getMcName(), pCurrentPage.getNextHighestDepth(), tX, tY, tW, tH)
cnt = tSettings.count
repeat with i = 1 to cnt
mc[tSettings.getPropAt(i)] = tSettings[i]
end repeat
fmt = pFlashSprite.newObject("TextFormat")
-- defaults
cnt = pTextFormat.count
repeat with i = 1 to cnt
fmt[pTextFormat.getPropAt(i)] = pTextFormat[i]
end repeat
if ilk(tFormat)=#propList then
cnt = tFormat.count
repeat with i = 1 to cnt
fmt[tFormat.getPropAt(i)] = tFormat[i]
end repeat
end if
mc.setNewTextFormat(fmt)
if ilk(tFormat)=#string then
my_styleSheet = pFlashSprite.newObject("TextField.StyleSheet")
my_styleSheet.parseCSS(tFormat)
mc.styleSheet = my_styleSheet
end if
if tSettings["html"] then
mc.html = true
mc.htmlText = tText
else
mc.html = false
mc.text = tText
end if
if pAutoPageBreak then
maxH = pPageFormat[2]-pMargins[#bottom]-tY
if mc._height>maxH then
-- FIND MAX. FITTING TEXT
maxFit = 0
n = 160
len = tText.length
cnt = len/n
repeat with i = 1 to cnt
mc.text = tText.char[1..i*n]
if mc._height>maxH then
maxFit = i*n-1
exit repeat
end if
end repeat
if maxFit=0 then
repeat with i = n*cnt to len
mc.text = tText.char[1..i]
if mc._height>maxH then
maxFit = i-1
exit repeat
end if
end repeat
end if
if maxFit>0 then
repeat with i = maxFit down to 1
if pBreakChars.getPos(tText.char[i]) then
mc.text = tText.char[1..i]
if mc._height<=maxH then
maxFit = i
exit repeat
end if
end if
end repeat
me.mAddPage()
tY = pMargins[#top]
return me.mAddText(tText.char[maxFit+1..tText.length], tX, tY, tW, tH, tSettings, tFormat)
--return tY + mc._height
else
put "ERROR"
end if
end if
end if
return tY + mc.textHeight
end
----------------------------------------
-- Returns width of string when printed with current/specified format
-- @param string tText
-- @param propList tSettings: (optional) propList of setting-values
-- @param propList|string tFormat: (optional) propList of setting-values or a CSS string
--
-- @return float
--
-- @see mAddText
----------------------------------------
on mGetTextWidth (me, tText, tSettings, tFormat)
if voidP(tSettings) then tSettings=[:]
mc = pCurrentPage.createTextField(me._getMcName(), pCurrentPage.getNextHighestDepth(), 0, 0, 1000, 1000)
cnt = tSettings.count
repeat with i = 1 to cnt
mc[tSettings.getPropAt(i)] = tSettings[i]
end repeat
fmt = pFlashSprite.newObject("TextFormat")
-- defaults
cnt = pTextFormat.count
repeat with i = 1 to cnt
fmt[pTextFormat.getPropAt(i)] = pTextFormat[i]
end repeat
if ilk(tFormat)=#propList then
cnt = tFormat.count
repeat with i = 1 to cnt
fmt[tFormat.getPropAt(i)] = tFormat[i]
end repeat
end if
mc.setNewTextFormat(fmt)
if ilk(tFormat)=#string then
my_styleSheet = pFlashSprite.newObject("TextField.StyleSheet")
my_styleSheet.parseCSS(tFormat)
mc.styleSheet = my_styleSheet
end if
--mc.wordWrap = 0 -- ???
if tSettings["html"] then
mc.html = true
mc.htmlText = tText
else
mc.html = false
mc.text = tText
end if
w = mc.textWidth
mc.removeTextField()
return w
end
----------------------------------------
-- Adds an image to the document at the specified position
-- @param image tImage
-- @param integer tX
-- @param integer tY
-- @param integer tW: (optional)
-- @param integer tH: (optional)
-- @param propList tSettings: (optional)
----------------------------------------
on mAddImage (me, tImage, tX, tY, tW, tH, tSettings)
if voidP(tW) then tW = tImage.width
if voidP(tH) then tH = tW * tImage.height/tImage.width
if voidP(tSettings) then tSettings=[:]
myBitmapData = pFlashSprite.convert(#BitmapData, tImage)
pBitmaps.add(myBitmapData)
mc = pCurrentPage.createEmptyMovieClip(me._getMcName(), pCurrentPage.getNextHighestDepth() )
-- public attachBitmap(bmp:BitmapData, depth:Number, [pixelSnapping:String], [smoothing:Boolean]) : Void
mc.attachBitmap(myBitmapData, 1)
mc._x = tX
mc._y = tY
mc._width = tW
mc._height = tH
cnt = tSettings.count
repeat with i = 1 to cnt
mc[tSettings.getPropAt(i)] = tSettings[i]
end repeat
--myBitmapData.dispose() -- ???
if pPrintAsBitmap.getPos(pCurrentPageNum)=0 then pPrintAsBitmap.add(pCurrentPageNum)
end
--**************************************
-- SETTINGS
--**************************************
----------------------------------------
-- Sets the draw color
-- @param color tColor
----------------------------------------
on mSetDrawColor (me, tColor)
pLineStyle["rgb"] = "0x" & tColor.hexString().char[2..7]
end
----------------------------------------
-- Sets the fill color
-- @param color tColor
----------------------------------------
on mSetFillColor (me, tColor)
pFillColor = "0x" & tColor.hexString().char[2..7]
end
----------------------------------------
-- Sets the fill alpha value
-- @param integer tAlpha: 0=transparent, 100=opaque
----------------------------------------
on mSetFillAlpha (me, tAlpha)
pFillAlpha = tAlpha
end
----------------------------------------
-- Sets the default text format for all text
-- @param propList tFormat: propList of format-values (as flash-style); see "format.htm" for list of supported values
----------------------------------------
on mSetTextFormat (me, tFormat)
cnt = tFormat.count
repeat with i = 1 to cnt
pTextFormat[tFormat.getPropAt(i)] = tFormat[i]
end repeat
end
----------------------------------------
-- Sets the text color
-- @param color tColor
----------------------------------------
on mSetTextColor (me, tColor)
pTextFormat["color"] = "0x" & tColor.hexString().char[2..7]
end
----------------------------------------
-- Sets the font
-- @param string tFont
----------------------------------------
on mSetFont (me, tFont)
pTextFormat["font"] = tFont
end
----------------------------------------
-- Sets the fontsize
-- @param float tFontSize
----------------------------------------
on mSetFontSize (me, tFontSize)
pTextFormat["size"] = tFontSize
end
----------------------------------------
-- Sets the linestyle
-- @param propList tLineStyle: supported properties: thickness:Number, rgb:Number, alpha:Number, pixelHinting:Boolean, noScale:String, capsStyle:String, jointStyle:String, miterLimit:Number
----------------------------------------
on mSetLineStyle (me, tLineStyle)
cnt = tLineStyle.count
repeat with i = 1 to cnt
pLineStyle[tLineStyle.getPropAt(i)] = tLineStyle[i]
end repeat
end
--**************************************
-- DRAW
--**************************************
----------------------------------------
-- Draws a line
-- @param integer tX1
-- @param integer tY1
-- @param integer tX2
-- @param integer tY2
-- @param propList tLineGradProps: (optional)
----------------------------------------
on mAddLine (me, tX1, tY1, tX2, tY2, tLineGradProps)
mc = pCurrentPage.createEmptyMovieClip(me._getMcName(), pCurrentPage.getNextHighestDepth())
me._setLineStyle(mc)
if listP(tLineGradProps) then
me._setGradientLineStyle(mc, tLineGradProps)
end if
mc.moveTo(tX1, tY1)
mc.lineTo(tX2, tY2)
end
----------------------------------------
-- Draws a rect
-- @param integer tX
-- @param integer tY
-- @param integer tW
-- @param integer tH
-- @param string tStyle: (optional) "D" for draw (=default), "F" for fill, "DF" for both
-- @param propList tLineGradProps: (optional)
-- @param propList tFillGradProps: (optional)
----------------------------------------
on mAddRect (me, tX, tY, tW, tH, tStyle, tLineGradProps, tFillGradProps)
if voidP(tStyle) then tStyle="D"
mc = pCurrentPage.createEmptyMovieClip(me._getMcName(), pCurrentPage.getNextHighestDepth())
if tStyle contains "D" then
me._setLineStyle(mc)
if listP(tLineGradProps) then
me._setGradientLineStyle(mc, tLineGradProps)
end if
end if
if tStyle contains "F" then
if listP(tFillGradProps) then
me._setGradientFill(mc, tFillGradProps)
else
mc.beginFill(pFillColor, pFillAlpha)
end if
end if
mc.moveTo(tX, tY)
mc.lineTo(tX+tW, tY)
mc.lineTo(tX+tW, tY+tH)
mc.lineTo(tX, tY+tH)
mc.lineTo(tX, tY)
if tStyle contains "F" then mc.endFill()
end
----------------------------------------
-- Draws a rounded rect
-- @param integer tX
-- @param integer tY
-- @param integer tW
-- @param integer tH
-- @param integer tR
-- @param string tStyle: (optional) "D" for draw (=default), "F" for fill, "DF" for both
-- @param propList tLineGradProps: (optional)
-- @param propList tFillGradProps: (optional)
----------------------------------------
on mAddRoundedRect (me, tX, tY, tW, tH, tR, tStyle, tLineGradProps, tFillGradProps)
if voidP(tStyle) then tStyle="D"
mc = pCurrentPage.createEmptyMovieClip(me._getMcName(), pCurrentPage.getNextHighestDepth())
if tStyle contains "D" then
me._setLineStyle(mc)
if listP(tLineGradProps) then
me._setGradientLineStyle(mc, tLineGradProps)
end if
end if
if tStyle contains "F" then
if listP(tFillGradProps) then
me._setGradientFill(mc, tFillGradProps)
else
mc.beginFill(pFillColor, pFillAlpha)
end if
end if
mc.moveTo(tX+tR, tY+0)
mc.lineTo(tX+tW - tR, tY+0)
mc.curveTo(tX+tW, tY+0, tX+tW, tY+tR)
mc.lineTo(tX+tW, tY+tR)
mc.lineTo(tX+tW, tY+tH - tR)
mc.curveTo(tX+tW, tY+tH, tX+tW - tR, tY+tH)
mc.lineTo(tX+tW - tR, tY+tH)
mc.lineTo(tX+tR, tY+tH)
mc.curveTo(tX+0, tY+tH, tX+0, tY+tH - tR)
mc.lineTo(tX+0, tY+tH - tR)
mc.lineTo(tX+0, tY+tR)
mc.curveTo(tX+0, tY+0,tX+tR, tY+0)
mc.lineTo(tX+tR, tY+0)
if tStyle contains "F" then mc.endFill()
end
----------------------------------------
-- Draws a circle or oval
-- @param integer tX
-- @param integer tY
-- @param integer tRX
-- @param integer tRY: (optional)
-- @param string tStyle: (optional) "D" for draw (=default), "F" for fill, "DF" for both
-- @param propList tLineGradProps: (optional)
-- @param propList tFillGradProps: (optional)
----------------------------------------
on mAddOval (me, tX, tY, tRX, tRY, tStyle, tLineGradProps, tFillGradProps)
if voidP(tStyle) then tStyle="D"
if voidP(tRY) then tRY=tRX
mc = pCurrentPage.createEmptyMovieClip(me._getMcName(), pCurrentPage.getNextHighestDepth())
if tStyle contains "D" then
me._setLineStyle(mc)
if listP(tLineGradProps) then
me._setGradientLineStyle(mc, tLineGradProps)
end if
end if
if tStyle contains "F" then
if listP(tFillGradProps) then
me._setGradientFill(mc, tFillGradProps)
else
mc.beginFill(pFillColor, pFillAlpha)
end if
end if
mc.moveTo(tX+tRX, tY)
angleDelta = PI / 4
xCtrlDist = tRX/cos(angleDelta/2)
yCtrlDist = tRY/cos(angleDelta/2)
a = 0
repeat with i = 1 to 8
a = a + angleDelta
cx = tX + cos(a-(angleDelta/2))*(xCtrlDist)
cy = tY + sin(a-(angleDelta/2))*(yCtrlDist)
ax = tX + cos(a)*tRX
ay = tY + sin(a)*tRY
mc.curveTo(cx, cy, ax, ay)
end repeat
if tStyle contains "F" then mc.endFill()
end
----------------------------------------
-- Draws a polygon
-- @param list tPoints: List of points
-- @param string tStyle: (optional) "D" for draw (=default), "F" for fill, "DF" for both
-- @param propList tLineGradProps: (optional)
-- @param propList tFillGradProps: (optional)
----------------------------------------
on mAddPoly (me, tPoints, tStyle, tLineGradProps, tFillGradProps)
if voidP(tStyle) then tStyle="D"
mc = pCurrentPage.createEmptyMovieClip(me._getMcName(), pCurrentPage.getNextHighestDepth())
if tStyle contains "D" then
me._setLineStyle(mc)
if listP(tLineGradProps) then
me._setGradientLineStyle(mc, tLineGradProps)
end if
end if
if tStyle contains "F" then
if listP(tFillGradProps) then
me._setGradientFill(mc, tFillGradProps)
else
mc.beginFill(pFillColor, pFillAlpha)
end if
end if
cnt = count(tPoints)
p0 = tPoints[1]
mc.moveTo(p0[1], p0[2])
repeat with i = 2 to cnt
p = tPoints[i]
mc.lineTo(p[1], p[2])
end repeat
mc.lineTo(p0[1], p0[2])
if tStyle contains "F" then mc.endFill()
end
----------------------------------------
-- Draws a quadratic bezier curve
-- @param list tPoints: List of points, alternately a control and an anchor point
-- @param string tStyle: (optional) "D" for draw (=default), "F" for fill, "DF" for both
-- @param propList tLineGradProps: (optional)
-- @param propList tFillGradProps: (optional)
----------------------------------------
on mAddCurve (me, tPoints, tStyle, tLineGradProps, tFillGradProps)
if voidP(tStyle) then tStyle="D"
mc = pCurrentPage.createEmptyMovieClip(me._getMcName(), pCurrentPage.getNextHighestDepth())
if tStyle contains "D" then
me._setLineStyle(mc)
if listP(tLineGradProps) then
me._setGradientLineStyle(mc, tLineGradProps)
end if
end if
if tStyle contains "F" then
if listP(tFillGradProps) then
me._setGradientFill(mc, tFillGradProps)
else
mc.beginFill(pFillColor, pFillAlpha)
end if
end if
p0 = tPoints[1]
mc.moveTo(p0[1], p0[2])
cnt = (count(tPoints)-1)/2
repeat with i = 1 to cnt
p1 = tPoints[2*i]
p2 = tPoints[2*i+1]
mc.curveTo(p1[1], p1[2], p2[1], p2[2])
end repeat
if tStyle contains "F" then mc.endFill()
end
----------------------------------------
-- Explicitely sets the printMode for the specified page
-- @param integer tPageNum
-- @param integer tBool
----------------------------------------
on mSetPagePrintAsBitmapMode (me, tPageNum, tBool)
if voidP(tBool) then tBool=1
if tBool then
if pPrintAsBitmap.getPos(tPageNum)=0 then
pPrintAsBitmap.add(tPageNum)
end if
else
pPrintAsBitmap.deleteOne(tPageNum)
end if
end
----------------------------------------
-- Returns an image of the specified page (as 72 dpi)
-- @param integer tPageNum: pageNumber as integer
-- @param integer tAddBorder: (optional) if specified and true, a 1px black border will be drawn around the page image
--
-- @return image
----------------------------------------
on mGetPreview (me, tPageNum, tAddBorder)
mc = pFlashSprite["page"&tPageNum]
bmp = pFlashSprite.newObject("flash.display.BitmapData", pPageFormat[1], pPageFormat[2]) --output_vid._width,output_vid._height);
--matrix = pFlashSprite.newObject("flash.geom.Matrix")
bmp.draw(mc) --, matrix)
img = pFlashSprite.convert(#image, bmp)
if (tAddBorder) then
img.draw(img.rect, [#shapeType:#rect, #lineSize:1, #color:RGB(0,0,0)])
end if
bmp.dispose()
return img
end
----------------------------------------
-- Prints the current document
-- @param integer tPrintAllPagesAsBitmap: (optional) if specified, forces to print all pages as bitmap, ignoring the previous settings
--
-- @return integer (1 or 0)
----------------------------------------
on mPrint (me, tPrintAllPagesAsBitmap)
if pPageCnt=0 then return false
options = pFlashSprite.newObject("Object")
myPrintJob = pFlashSprite.newObject("PrintJob")
ok = myPrintJob.start()
--> PrintJob.paperWidth
--> PrintJob.paperHeight
--> PrintJob.pageWidth
--> PrintJob.pageHeight
--> PrintJob.orientation
if ok then
repeat with i = 1 to pPageCnt
options.printAsBitmap = tPrintAllPagesAsBitmap OR (pPrintAsBitmap.getPos(i)>0)
ok = myPrintJob.addPage("page"&i, pPrintArea, options, 1)
end repeat
ok = myPrintJob.send()
else
put "ERROR: PrintJob couldn't be started!"
end if
-- delete myPrintJob
myPrintJob = VOID
return ok
end
----------------------------------------
-- This method is used to render the page header. It is automatically called by mAddPage() and
-- should not be called directly by the application. The implementation in the PRINT class is empty, so you have to
-- subclass it and override the method if you want a specific processing.
----------------------------------------
on mHeader me
nothing
end
----------------------------------------
-- This method is used to render the page footer. It is automatically called by mAddPage() and
-- should not be called directly by the application. The implementation in the PRINT class is empty, so you have to
-- subclass it and override the method if you want a specific processing.
----------------------------------------
on mFooter me
nothing
end
--**************************************
-- PRIVATE
--**************************************
----------------------------------------
--
----------------------------------------
on _getMcName (me)
pMcCnt = pMcCnt +1
return "mc"&pMcCnt
end
----------------------------------------
--
----------------------------------------
on _setLineStyle (me, mc)
mc.lineStyle(pLineStyle["thickness"],pLineStyle["rgb"],pLineStyle["alpha"],pLineStyle["pixelHinting"],pLineStyle["noScale"],pLineStyle["capsStyle"],pLineStyle["jointStyle"],pLineStyle["miterLimit"])
end
----------------------------------------
--
----------------------------------------
on _setGradientLineStyle (me, mc, props)
if voidP(props["rotation"]) then props["rotation"]=0
if voidP(props["tx"]) then props["tx"]=0
if voidP(props["ty"]) then props["ty"]=0
if voidP(props["spreadMethod"]) then props["spreadMethod"]="pad"
if voidP(props["interpolationMethod"]) then props["interpolationMethod"]="RGB"
if voidP(props["focalPointRatio"]) then props["focalPointRatio"]=0
fillType = props["fillType"]
colors = pFlashSprite.convert(#flashObjectArray, props["colors"])
alphas = pFlashSprite.convert(#flashObjectArray, props["alphas"])
ratios = pFlashSprite.convert(#flashObjectArray, props["ratios"])
matrix = pFlashSprite.newObject("flash.geom.Matrix")
-- public createGradientBox(width:Number, height:Number, [rotation:Number], [tx:Number], [ty:Number]) : Void
matrix.createGradientBox(props["width"], props["height"], props["rotation"], props["tx"], props["ty"])
spreadMethod = props["spreadMethod"]
interpolationMethod = props["interpolationMethod"]
focalPointRatio = props["focalPointRatio"]
mc.lineGradientStyle(fillType, colors, alphas, ratios, matrix, spreadMethod, interpolationMethod, focalPointRatio)
end
----------------------------------------
--
----------------------------------------
on _setGradientFill(me, mc, props)
-- defaults
if voidP(props["rotation"]) then props["rotation"]=0
if voidP(props["tx"]) then props["tx"]=0
if voidP(props["ty"]) then props["ty"]=0
if voidP(props["spreadMethod"]) then props["spreadMethod"]="pad"
if voidP(props["interpolationMethod"]) then props["interpolationMethod"]="RGB"
if voidP(props["focalPointRatio"]) then props["focalPointRatio"]=0
fillType = props["fillType"]
colors = pFlashSprite.convert(#flashObjectArray, props["colors"])
alphas = pFlashSprite.convert(#flashObjectArray, props["alphas"])
ratios = pFlashSprite.convert(#flashObjectArray, props["ratios"])
matrix = pFlashSprite.newObject("flash.geom.Matrix")
-- public createGradientBox(width:Number, height:Number, [rotation:Number], [tx:Number], [ty:Number]) : Void
matrix.createGradientBox(props["width"], props["height"], props["rotation"], props["tx"], props["ty"])
spreadMethod = props["spreadMethod"]
interpolationMethod = props["interpolationMethod"]
focalPointRatio = props["focalPointRatio"]
mc.beginGradientFill(fillType, colors, alphas, ratios, matrix, spreadMethod, interpolationMethod, focalPointRatio)
end