Search code examples
flashactionscript-3runtimeshapesstroke

How to change Shape border stroke runtime in Actionsctipt 3


I've got a complicated shape in a MovieClip.
Runtime i want to change the stroke width of this Shape depending on a size ratio.

How can I change this property without redrawing the entire Shape with the drawing API (almost impossible, is a map with very detailed borders) ?

Is it possible ?


Solution

  • It's tricky, but possible.

    You can use as3swf to parse the shape, change the lineStyle record, publish it and read it back in to your master SWF. Flash Player 10 would be required for as3swf to work.

    as3swf: http://github.com/claus/as3swf

    Example: http://github.com/claus/as3swf/tree/master/examples/flexmania/ (see 4 - PublishModifiedLogo.fla)

    You may want to reconsider redrawing the modified shape though. as3swf features export of shapes to GraphicsData, and Graphics.drawGraphicsData() is very fast.