<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" 
      xmlns:thr="http://purl.org/syndication/thread/1.0">
  <link rel="alternate" type="text/html" href="http://www.insideria.com/2008/03/try-out-the-drawing-api-withou.html" />
  <link rel="self" type="application/atom+xml" href="http://www.insideria.com/atom.xml" />
  <id>tag:www.insideria.com,2009://34/tag:www.insideria.com,2008://34.23182-</id>
  <updated>2009-11-05T20:17:39Z</updated>
  <title>Comments for Try Out The Drawing API... Without Compiling Anything! (http://www.insideria.com/2008/03/try-out-the-drawing-api-withou.html)</title>
  <generator uri="http://www.sixapart.com/movabletype/">Movable Type 4.21-en</generator>
  <entry>
    <id>tag:www.insideria.com,2008://34.23182</id>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2008/03/try-out-the-drawing-api-withou.html" />
    <link rel="service.edit" type="application/atom+xml" href="http://blogs.oreilly.com/cgi-bin/mt/mt-atom.cgi/weblog/blog_id=34/entry_id=23182" title="Try Out The Drawing API... Without Compiling Anything!" />
    <published>2008-03-21T00:42:53Z</published>
    <updated>2008-03-21T01:29:56Z</updated>
    <title>Try Out The Drawing API... Without Compiling Anything!</title>
    <summary>

My last few posts on the Flash/Flex/ActionScript drawing API gave me a few ideas...   Everyone always says how it reminds them of old-school programming in BASIC or Pascal.   I decided to make it easier for anyone to play with the drawing API, without having to compile any programs for themselves.   I call this the &quot;Drawing API Explorer&quot;.  Using the drawing API explorer application, you don&apos;t have to override updateDisplayList or anything.  All of the hard work is done.</summary>
    <author>
      <name>Andrew Trice</name>
      
    </author>
    
    <category term="Blogs" />
    
    <content type="html" xml:lang="en" xml:base="http://www.insideria.com/">
      <![CDATA[<div class="ap_r" style="margin: 16px;"><a href="http://www.insideria.com/upload/2008/03/try_out_the_drawing_api_withou/spiral.jpg" class="highslide" onclick="return hs.expand(this)"><img src="http://www.insideria.com/upload/2008/03/try_out_the_drawing_api_withou/spiral.jpg" alt="spiral.jpg" title="Click to enlarge" width="148"/></a></div>

<p>My last few posts on the <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=Drawing_Vector_Graphics_1.html" target="_blank">Flash/Flex/ActionScript drawing API</a> gave me a few ideas...   Everyone always says how it reminds them of old-school programming in BASIC or Pascal.   I decided to make it easier for anyone to play with the drawing API, without having to compile any programs for themselves.   I call this the "<strong>Drawing API Explorer</strong>".  Using the drawing API explorer application, you don't have to override updateDisplayList or anything.  All of the hard work is done.</p>

<p>This example uses runtime code evaluation to draw shapes using the <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=Drawing_Vector_Graphics_1.html" target="_blank">ActionScript drawing API</a>.  Check it out below!  </p>

<p>There are two tabs.  The first tab allows you to type in code that will be executed when you click on the "run" button.   The second tab shows you a bunch of ActionScript drawing API examples.  Just click on an example name in the left, and the code will be displayed.  You can run the examples by clicking on the "run this example" button, or you can edit the example code by clicking on the "edit this example" button.  When you click on the "edit" button, it will switch over to the first tab and paste the code into there.... Be careful!  It will clear whatever was in there previously.</p>

<p>You can use any kind of loops, if-statements, switch statements, etc...   It supports all methods of the Graphics, Math, and Matrix ActionScript classes.   You can use the variable <strong>g</strong> to represent the graphics object, the variable <strong>w</strong> to represent the draw target area width, and the variable <strong>h</strong> to represent draw target area height. I have tried the following, and know they work:</p>

<ul>
	<li>g.lineStyle</li>
	<li>g.beginFill</li>
	<li>g.endFill</li>
	<li>g.moveTo</li>
	<li>g.lineTo</li>
	<li>g.curveTo</li>
	<li>g.drawRect</li>
	<li>g.drawRoundRect</li>
	<li>g.drawCircle</li>
</ul>

<p>See the <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=Drawing_Vector_Graphics_1.html" target="_blank">ActionScript drawing API</a> documentation for more information about the drawing API syntax and capabilities.</p>

<p>Go ahead and test it out here: <script src="http://www.tricedesigns.com/portfolio/actionscriptshapes/swfobject.js" type="text/javascript"></script>	<div id="flashcontent">  This text is replaced by the Flash movie DrawingAPIExplorer.</div>	<script>	var so = new SWFObject("http://www.tricedesigns.com/portfolio/DrawingAPIExplorer/DrawingAPIExplorer.swf", "DrawingAPIExplorer", "425", "525", "8", "#000000");	so.write("flashcontent");</script></p>

<p><br />
The runtime code evaluation uses the <a href="http://www.riaone.com/deval/" target="_blank">D.eval()</a> code library.  The D.eval() API is a SWC library for Flex applications that enables the runtime generation and execution of code and expressions in ActionScript 3. </p>

<p>You can launch this application in a new window here:<br />
<a href="http://www.tricedesigns.com/portfolio/DrawingAPIExplorer/DrawingAPIExplorer.html" target="_blank">http://www.tricedesigns.com/portfolio/DrawingAPIExplorer/DrawingAPIExplorer.html</a></p>

<p>View the source code here:<br />
<a href="http://www.tricedesigns.com/portfolio/DrawingAPIExplorer/srcview/index.html" target="_blank">http://www.tricedesigns.com/portfolio/DrawingAPIExplorer/srcview/index.html</a></p>

<p>Or, download the source code here:<br />
<a href="http://www.tricedesigns.com/portfolio/DrawingAPIExplorer/srcview/DrawingAPIExplorer.zip" target="_blank">http://www.tricedesigns.com/portfolio/DrawingAPIExplorer/srcview/DrawingAPIExplorer.zip</a><br />
</p>]]>
      
    </content>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2008://34.23182-comment:2016048</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2008://34.23182" type="text/html" href="http://www.insideria.com/2008/03/try-out-the-drawing-api-withou.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2008/03/try-out-the-drawing-api-withou.html#comment-2016048" />
    <title>Comment from funkyboy on 2008-03-21</title>
    <author>
        <name>funkyboy</name>
        <uri>http://spreadingfunkyness.com</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://spreadingfunkyness.com">
        <![CDATA[<p>Very cool example! <br />
Will experiment with that.<br />
Thanks!</p>]]>
    </content>
    <published>2008-03-21T15:47:57Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2008://34.23182-comment:2045000</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2008://34.23182" type="text/html" href="http://www.insideria.com/2008/03/try-out-the-drawing-api-withou.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2008/03/try-out-the-drawing-api-withou.html#comment-2045000" />
    <title>Comment from chusty on 2008-10-29</title>
    <author>
        <name>chusty</name>
        <uri>http://pl.lennylamb.com</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://pl.lennylamb.com">
        <![CDATA[<p>still trying to figure out whether id needs compiling or not ?</p>]]>
    </content>
    <published>2008-10-29T17:19:07Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2008://34.23182-comment:2049190</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2008://34.23182" type="text/html" href="http://www.insideria.com/2008/03/try-out-the-drawing-api-withou.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2008/03/try-out-the-drawing-api-withou.html#comment-2049190" />
    <title>Comment from myneni koteshwar rao on 2008-12-18</title>
    <author>
        <name>myneni koteshwar rao</name>
        <uri></uri>
    </author>
    <content type="html" xml:lang="en" xml:base="">
        <![CDATA[<p>great... its very use full for me.</p>

<p>thanks.</p>]]>
    </content>
    <published>2008-12-19T04:19:31Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2008://34.23182-comment:2057340</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2008://34.23182" type="text/html" href="http://www.insideria.com/2008/03/try-out-the-drawing-api-withou.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2008/03/try-out-the-drawing-api-withou.html#comment-2057340" />
    <title>Comment from Luc Martin on 2009-04-10</title>
    <author>
        <name>Luc Martin</name>
        <uri>http://pangym.com</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://pangym.com">
        <![CDATA[<p>Thank you so much for this awesome work!</p>]]>
    </content>
    <published>2009-04-10T23:28:31Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2008://34.23182-comment:2059596</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2008://34.23182" type="text/html" href="http://www.insideria.com/2008/03/try-out-the-drawing-api-withou.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2008/03/try-out-the-drawing-api-withou.html#comment-2059596" />
    <title>Comment from Shweta on 2009-05-13</title>
    <author>
        <name>Shweta</name>
        <uri></uri>
    </author>
    <content type="html" xml:lang="en" xml:base="">
        <![CDATA[<p>Hi Andrew</p>

<p>This is all very nice.</p>

<p>I just need to know how to draw semicircle with using curve.<br />
Can u provide some example please?</p>]]>
    </content>
    <published>2009-05-14T06:56:41Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2008://34.23182-comment:2059926</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2008://34.23182" type="text/html" href="http://www.insideria.com/2008/03/try-out-the-drawing-api-withou.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2008/03/try-out-the-drawing-api-withou.html#comment-2059926" />
    <title>Comment from Mark on 2009-05-19</title>
    <author>
        <name>Mark</name>
        <uri></uri>
    </author>
    <content type="html" xml:lang="en" xml:base="">
        <![CDATA[<p>To draw a semi-circle take a look at the drawWedge code in the following article:</p>

<p><a href="http://www.adobe.com/devnet/flash/articles/adv_draw_methods.html">http://www.adobe.com/devnet/flash/articles/adv_draw_methods.html</a></p>]]>
    </content>
    <published>2009-05-19T19:48:48Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2008://34.23182-comment:2114462</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2008://34.23182" type="text/html" href="http://www.insideria.com/2008/03/try-out-the-drawing-api-withou.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2008/03/try-out-the-drawing-api-withou.html#comment-2114462" />
    <title>Comment from Alex Fisherr on 2009-09-24</title>
    <author>
        <name>Alex Fisherr</name>
        <uri></uri>
    </author>
    <content type="html" xml:lang="en" xml:base="">
        <![CDATA[<p>Nice Post. Got some ideas I was looking for. One thing that I want to know more about is the option of erasing the drawings on a canvas. What if I want to erase a limited portion of a circle without removing the entire object?<br />
I mean that if there is an image that I am working on and I draw some custom lines on it. How will I remove the line that is a bit misplaced from the target if the option of Undo is not there. Unlike MS Paint, where the eraser actually fills the space with selected color rather than removing the drawing. e.g, if you are editing a photo and you select the eraser, it leaves the mark on the photo which is strictly unwanted.</p>

<p>Can anybody help ?</p>

<p>Regards,</p>

<p>Alex Fisherr</p>]]>
    </content>
    <published>2009-09-24T12:03:48Z</published>
  </entry>

</feed
