title: ActionScript Drawing Code From Vector Graphic?
body: <p>is there a common way to convert a drawn vector graphic in Flash Professional to code for the Drawing API?</p>
  
  <p>the code of these drawn or imported vector graphic assets are available in the source files (.xfl) as XML data.  for example, the following drawn vector graphic is the trailing XML data.</p>
  
  <p><img src="https://i.stack.imgur.com/g2NHm.png" alt="enter image description here"></p>
  
  <pre><code>&lt;DOMSymbolItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://ns.adobe.com/xfl/2008/" name="MSprite" itemID="4e03ae4f-00002c0f" linkageExportForAS="true" linkageBaseClass="flash.display.Sprite" linkageClassName="MSprite" sourceLibraryItemHRef="Symbol 1" lastModified="1308864079" isSpriteSubclass="true"&gt;
    &lt;timeline&gt;
      &lt;DOMTimeline name="MSprite"&gt;
        &lt;layers&gt;
          &lt;DOMLayer name="Layer 1" color="#4FFF4F" current="true" isSelected="true"&gt;
            &lt;frames&gt;
              &lt;DOMFrame index="0" keyMode="9728"&gt;
                &lt;elements&gt;
                  &lt;DOMShape&gt;
                    &lt;fills&gt;
                      &lt;FillStyle index="1"&gt;
                        &lt;SolidColor color="#00CCFF"/&gt;
                      &lt;/FillStyle&gt;
                    &lt;/fills&gt;
                    &lt;strokes&gt;
                      &lt;StrokeStyle index="1"&gt;
                        &lt;SolidStroke scaleMode="normal"&gt;
                          &lt;fill&gt;
                            &lt;SolidColor/&gt;
                          &lt;/fill&gt;
                        &lt;/SolidStroke&gt;
                      &lt;/StrokeStyle&gt;
                    &lt;/strokes&gt;
                    &lt;edges&gt;
                      &lt;Edge fillStyle0="1" strokeStyle="1" edges="!6883 745S5[6369 340 5741 148!5741 148[5534 85 5314 78!5314 78[4037 36 2754 2!2754 2[1956 -18 1222 211!1222 211[693 376 393 745!393 745[139 1056 48 1512!48 1512[-130 2404 354 3085!354 3085[799 3713 1505 3927!1505 3927[1675 3979 1817 3876
  !1817 3876[1970 3765 2071 3564!2071 3564|1474 3205!1474 3205[1230 2199 2029 1548!2029 1548[2144 1454 2274 1365!2274 1365|2834 1365!2834 1365|3194 1585!3194 1585|3254 1705!3254 1705|3434 2245!3434 2245|3514 2305!3514 2305[3652 1520 4512
   1353!4512 1353[5351 1190 5981 1839!5981 1839[6054 1915 6115 1995!6115 1995[6394 2358 6314 2845!6314 2845[6188 3617 6664 4084!6664 4084[6710 4129 6761 4171!6761 4171[6898 4282 7071 4308!7071 4308[7421 4359 7733 4184!7733 4184[7760 4134
   7785 4084!7785 4084[8238 3170 7920 2182!7920 2182[7733 1598 7325 1156!7325 1156[7115 929 6883 745"/&gt;
                      &lt;Edge cubics="!5741 148(;5603,106 5461,83 5314,78q5741 148Q5534 85q5314 78);"/&gt;
                      &lt;Edge cubics="!5981 1839(;6030,1890 6074,1942 6115,1995q5981 1839Q6054 1915q6115 1995);"/&gt;
                      &lt;Edge cubics="!6115 1995(;6301,2237 6367,2520 6314,2845q6115 1995Q6394 2358q6314 2845);"/&gt;
                      &lt;Edge cubics="!6761 4171(;6852,4245 6956,4291 7071,4308q6761 4171Q6898 4282q7071 4308);"/&gt;
                      &lt;Edge cubics="!6314 2845(;6230,3363 6348,3778 6664,4084q6314 2845Q6188 3617q6664 4084);"/&gt;
                      &lt;Edge cubics="!6664 4084(;6699,4118 6729,4145 6761,4171q6664 4084 6761 4171);"/&gt;
                      &lt;Edge cubics="!7733 4184(;7751,4152 7768,4119 7785,4084q7733 4184 7785 4084);"/&gt;
                      &lt;Edge cubics="!7785 4084(;8086,3476 8132,2842 7920,2182q7785 4084Q8238 3170q7920 2182);"/&gt;
                      &lt;Edge cubics="!4512 1353(;5071,1244 5561,1406 5981,1839q4512 1353Q5351 1190q5981 1839);"/&gt;
                      &lt;Edge cubics="!7071 4308(;7304,4342 7525,4301 7733,4184q7071 4308Q7421 4359q7733 4184);"/&gt;
                      &lt;Edge cubics="!7920 2182(;7795,1793 7597,1451 7325,1156q7920 2182Q7733 1598q7325 1156);"/&gt;
                      &lt;Edge cubics="!7325 1156(;7188,1007 7043,872 6883,745q7325 1156Q7115 929q6883 745);"/&gt;
                      &lt;Edge cubics="!6883 745(;6546,478 6163,277 5741,148q6883 745Q6369 340q5741 148);"/&gt;
                      &lt;Edge cubics="!2029 1548(;2106,1485 2187,1424 2274,1365q2029 1548Q2144 1454q2274 1365);"/&gt;
                      &lt;Edge cubics="!2834 1365(;2834,1365 3194,1585 3194,1585q2834 1365 3194 1585);"/&gt;
                      &lt;Edge cubics="!2274 1365(;2274,1365 2834,1365 2834,1365q2274 1365 2834 1365);"/&gt;
                      &lt;Edge cubics="!2754 2(;2222,-11 1711,58 1222,211q2754 2Q1956 -18q1222 211);"/&gt;
                      &lt;Edge cubics="!3254 1705(;3254,1705 3434,2245 3434,2245q3254 1705 3434 2245);"/&gt;
                      &lt;Edge cubics="!3434 2245(;3434,2245 3514,2305 3514,2305q3434 2245 3514 2305);"/&gt;
                      &lt;Edge cubics="!1505 3927(;1618,3962 1722,3945 1817,3876q1505 3927Q1675 3979q1817 3876);"/&gt;
                      &lt;Edge cubics="!1222 211(;870,321 594,498 393,745q1222 211Q693 376q393 745);"/&gt;
                      &lt;Edge cubics="!393 745(;224,951 109,1207 48,1512q393 745Q139 1056q48 1512);"/&gt;
                      &lt;Edge cubics="!1474 3205(;1311,2534 1496,1982 2029,1548q1474 3205Q1230 2199q2029 1548);"/&gt;
                      &lt;Edge cubics="!3194 1585(;3194,1585 3254,1705 3254,1705q3194 1585 3254 1705);"/&gt;
                      &lt;Edge cubics="!48 1512(;-71,2107 31,2631 354,3085q48 1512Q-130 2404q354 3085);"/&gt;
                      &lt;Edge cubics="!354 3085(;651,3504 1034,3784 1505,3927q354 3085Q799 3713q1505 3927);"/&gt;
                      &lt;Edge cubics="!3514 2305(;3606,1782 3939,1464 4512,1353q3514 2305Q3652 1520q4512 1353);"/&gt;
                      &lt;Edge cubics="!5314 78(;4463,50 3609,25 2754,2q5314 78Q4037 36q2754 2);"/&gt;
                      &lt;Edge cubics="!2071 3564(;2071,3564 1474,3205 1474,3205q2071 3564 1474 3205);"/&gt;
                      &lt;Edge cubics="!1817 3876(;1919,3802 2004,3698 2071,3564q1817 3876Q1970 3765q2071 3564);"/&gt;
                    &lt;/edges&gt;
                  &lt;/DOMShape&gt;
                &lt;/elements&gt;
              &lt;/DOMFrame&gt;
            &lt;/frames&gt;
          &lt;/DOMLayer&gt;
        &lt;/layers&gt;
      &lt;/DOMTimeline&gt;
    &lt;/timeline&gt;
  &lt;/DOMSymbolItem&gt;
  </code></pre>
  
  <p>this proves that it would be certainly possible to create a utility that could port the XML code to AS3.  in doing so, AS3 developers wouldn't have to worry about handling vector assets, especially if they migrate away from Flash Professional to Flash Builder.  </p>
  
  <p>personally, i'm interested in creating a utility for this eventually if there is not one available already, but i'd like to know if there is one already available?</p>
  
  <hr>
  
  <p><strong>[EDIT]</strong></p>
  
  <p>since i've posted this question i've learned of the SVG Web Project, which contains a branch for ActionScript 3.0 for reading SVG data and adding it to the display list. the library allows developers to create SVG graphics and embed the source code as an XML literal.  while this still doesn't open up the possibility of simply editing graphics using the Drawing API, it's not so difficult to edit the SVG XML and it makes it possible to avoid using .swf assets for graphics in Flash Builder.  the library isn't perfect, my brief time spent with it i've leared that it doesn't seem to render radial gradients with more than 2 colors, and it doesn't allow scaling (it appears you can only change the width and height properties, which is both strange and very unfortunate), but at least now i can include the code for the graphics instead of using assets.</p>
  
  <p>source:  <a href="http://labs.zavoo.com/?p=238" rel="nofollow noreferrer">com.zavoo.labs - New Flex and Flash SVGWeb Components</a></p>