View Full Version : Challenge - Getting drawing data

02-15-2010, 10:14 AM
The object of this challenge is to create a function that returns an array of arrays for the shapes defined by a timeline.

interface DrawingDataFinder {
function doIt(timelineClass:Class,bytes:ByteArray):Vector.<DrawingData>;

class DrawingData {
var commands:Vector.<int>, data:Vector.<Number>;

Each object in the array has to be the needed data to call Graphics.drawPath to duplicate the shapes defined by the symbol in question. The bytes argument is the content of the swf file in question.

04-08-2010, 08:14 AM
And, AFAIK, SamHaXe does that too. So, looks like we may have an early winner ;)

01-09-2011, 08:04 AM
Using drawing style data

In the "Using drawing data" section, we loaded Vector objects as drawing data for the Graphics.drawPath() method. Now, we'll define some drawing style objects we can use as parameters for the Graphics.drawGraphicsData() method. The Graphics.drawGraphicsData() method is a very powerful implementation of the new drawing API. This method uses objects created by the classes that implement the flash.display.IGraphicsData interface. The classes are as follows:

* GraphicsBitmapFill
* GraphicsEndFill
* GraphicsGradientFill
* GraphicsPath
* GraphicsShaderFill
* GraphicsSolidFill
* GraphicsStroke
* GraphicsTrianglePath

Each class creates an object of properties that define the style of a fill, stroke, or path accordingly. Pass those objects as parameters to Graphics.drawGraphicsData() to render a drawing according to the defined properties. Once you define your drawing objects, you can reuse them for other shapes, so your drawing properties are centralized and transferable.

This first example populates the IGraphicsData object with only fill and path data. For the drawing data, this example uses the following:

* GraphicsSolidFill class for the fill properties
* GraphicsPath class for the outline of the shape

// establish the fill properties

var myFill:GraphicsSolidFill = new GraphicsSolidFill();

myFill.color = 0x33CCFF; // establish the path properties

var myPath:GraphicsPath = new GraphicsPath(new Vector.<int>(),

new Vector.<Number>());


myPath.data.push(10,10, 10,100, 100,100, 100,10, 10,10); // populate the IGraphicsData Vector array

var myDrawing:Vector.<IGraphicsData> = new Vector.<IGraphicsData>();
myDrawing.push(myFill, myPath); // render the drawing