XML to ActionScript #3 (AsXML)

  1. <code>
  2.   <make reference="w" class="BasicView" args="stage.stageWidth, stage.stageHeight, false"/>
  3.   <call method="addChild" args="w"/>
  5.   <make reference="wireMat" class="WireframeMaterial" args="0x000000" />
  7.   <make reference="sphere" class="Sphere" args="wireMat, 100" />
  9.   <call method="w.scene.addChild" args="sphere" />
  11.   <make reference="animation" class="Object">
  12.     <set z="-500" rotationY="360"  rotationX="360" ease="Back.easeOut"/>
  13.   </make>
  15.   <call method="TweenLite.to" args="sphere, 3, animation" />
  17.   <call method="setInterval" args="w.singleRender, 32" />
  19. </code>

This snippet shows XML that the mini-library AsXML can read and run - in this case AsXML is set up to run with Papervision

A few days ago I had the idea to write some code that would run ActionScript based on XML. I spent some time getting rid of a few bugs and setting up some demos with TweenLite, Papervision and QuickBox2D. I wrapped everything up into a mini-library called AsXML.

Check out the demos here.

Download AsXML and demo files here.

AsXML Features:
1) call methods of the main timeline
2) read and write properties on the main timeline
3) instantiate classes on the main timeline
4) call methods on these classes
5) read and write properties on these classes
6) store references to return values from functions

This entry was posted in Box2D, Graphics, Math, QuickBox2D, XML, dynamic, external data, instantiation, misc, motion, return values, string manipulation, strings and tagged , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.


  1. Posted June 23, 2009 at 3:53 am | Permalink

    So it’ a bit like ANT, but for AS3. Interesting :)

  2. Posted June 23, 2009 at 11:13 am | Permalink

    @Mr.doob It’s sort of like ANT in the way the xml file is organized… but it doesn’t have anything to do with compiling/building… it just creates a bunch of dynamically typed objects at runtime based on the XML - it then sets properties and runs methods on those objects (again based on the XML file)… My knowledge of ANT isn’t all that extensive so maybe it does something like that for Java and I just wasn’t aware of it…

  3. Posted August 5, 2009 at 9:07 pm | Permalink

    i love you for this…

  4. Posted August 5, 2009 at 9:11 pm | Permalink

    thanks… if you end up using it on something cool… let me know…

  5. Posted August 6, 2009 at 11:50 pm | Permalink

    yea i got some cool stuff planned… can do some interesting serverside scripted as3/xml hybrid heh… last night I added to the class ability to do basic arithmetic in the xml which is really useful so you can do for loops on methods etc and basic string parsing like (4+4)/2 and in theory you could do vars too… which would be sick for loops (i*20) in xml heh

    i’m trying to fix one particular problem tho… it only seem s to compile with Flash CS4… i’ tried for a while last night and couldn’t figure out why i couldn’t get to compile via Flash Builder it has something to do with what “this” is considered … tonight i’ll try to use a document class+Flash CS4 but I think it will face same problem with targeting the root.

    Thanks alot for this one… i’ve been in search of solutions your works solve and may I say that is one beautiful parser class :)

  6. Posted August 7, 2009 at 7:38 am | Permalink

    Hey cmoore that sounds cool. What math parser did you use? for the (4+4)/2 stuff…

    it should work in flex, I can look at that a little later today… what is the error that your getting? the asxml class adds properties to the flash movie dynamically … so you’ll need to add the dynamic keyword to your document class - maybe that’s the problem…

  7. Posted August 9, 2009 at 8:23 pm | Permalink

    thanks zevan making it dynamic maked it work perfectly ;)

    i got my start for the string eval class here its proven really useful with xml so cant wait to try it with your classes.


    also another interesting library would be the AS3 eval library…

    thanks again for the blog really amazing stuff :)

  8. Posted August 10, 2009 at 12:55 am | Permalink

    cool… that flash and math lib from that post is the one I would recommend…

    I have an as3 eval library almost finished but its not as good as the flash and math one…

3 Trackbacks

  1. By [WEB]JustWEB20090623 | JustFLY::JustBlog:: on June 22, 2009 at 6:23 pm

    [...] 做一個跟twitter相同風格的logo嗎~ twitlogo 把任何的png圖片轉成PV3D object的class ExtrudeImage 這不是mxml… XML to ActionScript [...]

  2. [...] XML to ActionScript #3 (AsXML) [...]

  3. [...] – XML to ActionScript #3 (AsXML) [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *