Adding Simple Blender Models to CS4

December 27, 2008


One of my colleagues, Barbara Kaskosz just released a series of CS4 examples which I have been modifying to accept xml and blender models. Her examples can be found at

Barbara is a gifted coder, great person, and real honor to know – adding to her work is a head-rush for me! Click on the image below to run the CS4 Blender example.

Extending Barbara's Simple 3D Draw

Extending Barbara's Simple 3D Draw

Above is an example of a Blender model created in my Blender XML exporter brought into Barbara’s 3D Draw program.

Web Stuff


Download Source Code


Here are the steps I followed to enhance Barbara’s Simple 3D draw to accept Blender objects (this example does not included textured models I will be releasing that in an upcoming post).

  • I downloaded her code example Simple 3D Dynamic Drawing in Flash CS4 (use her Icosahedron example) and removed all the comments. The comments were great but they got in the way when I started to recode the example.
  • I then converted her timeline ActionScript code into a class package and ran it in Flex as an ActionScript Package. I’ve included that package in my download files.
  • Then I created a (non-textured) model in Blender and exported it using my XML Blender Exporter. I then placed that XML model file in Flex. (To learn how to model in Blender just click on my 3D modeling link in this blog. There are tons of getting started in Blender tutorials.)
  • Then I add the AS3 code needed to import the Blender XML model into Barbara’s Simple 3D program .

var externalXML:XML;
var loader:URLLoader = new URLLoader();
var request:URLRequest = new URLRequest(“testShip2.xml”);
loader.addEventListener(Event.COMPLETE, onComplete);

function onComplete(event:Event):void
var loader:URLLoader = as URLLoader;
if (loader != null)
externalXML = new XML(;

trace(“loader is not a URLLoader!”);


  • I then combined her setVertices() and setFaces() functions and placed an externalXML argument in the new combined setVertices(myData_xml:XML) function to bring in the XML data. I then split the CVS XML data into arrays and loaded the vertices and face indices XML data into Barbara’s vertsVec[i] and faceVec[i] vector arrays. In addition a scale factor was added to scale the Blender model.

private function setVertices(myData_xml:XML):void {
var mySlitVert:Array=
var mySlitFace:Array=

var myScale:Number=40;
var i:int;
vertsVec[i]= new Vector3D(mySlitVert[i*3]*myScale,mySlitVert[i*3+1]*myScale,
mySlitVert[i*3+2]*myScale); }

numFaces = (mySlitFace.length-1)/3;
var j:int;

  • Finally, I added a color vector array and randomly populated it . The colors were then applied to the Blender model faces. Everything else was the same as Barbara’s code.


Click the more button below to see the entire code and the Icosahedron class package.

Read the rest of this entry »


Get every new post delivered to your Inbox.