Integrating Papervision3D into the Adobe Flash Builder Sparks containers architecture.
It all started when I decided to try out the new Flex 4 Beta. The aim was to build Collada viewer that loads the dae files from the users’ filesystem / harddrive using new flash 10 FileRef API. What seemed like a pretty straightforward task turned into a Nightmare Lite after I realised I can’t just grab a new BasicView and dump it into a new sparks group container! The problem was, the group container didn’t support rawChildren.addChild(), as it didn’t contain rawChildren property.
After spending couple of hours trying and failing I came upon a working solution :

Use UIComponent as a wrapper for a BaseView which is implemented via composition. UIComponent is compatible with Sparks containers and can be added via addElement(); Thankfully UIComponents allows adding BaseView via addChild.. If you need to access a camera, scene, light etc, just use public variables on your UIComponent class to expose them and link them to your baseview camera lights etc.
This simple example utilises camera and materials light color change, but you can expose and change anything you like of course..
It is implemented directly inside of mxml but of course you could still have a group with id (let’s say “scene”) and add the whole component BasicView3D programmatically.
e.g. :
scene.addElement(new BasicView3D);
Check out the sample and right click to view source script and download the entire project.
Posted in AS3, Flex 4, papervision


July 7th, 2009 at 10:49 pm
Pure awesomeness!! Great work!!!
July 7th, 2009 at 11:31 pm
Very good work !!!
July 8th, 2009 at 1:20 am
[…] – #Papervision3D integrated into the new #Flex 4 "Spark" component model – http://durej.com/?p=110 (via @tomkrcha @ryanstewart) […]
July 13th, 2009 at 11:02 am
[…] – Papervision3D integrated into the new Flex 4 "Spark" component model – http://durej.com/?p=110 (via @tomkrcha) […]
May 18th, 2010 at 7:17 am
Pure awesomeness says it!
Just one change for the production release of Flex 4: Change (the last element, 2 instances in the example code) xmlns:mx=”library://ns.adobe.com/flex/halo to xmlns:mx=”library://ns.adobe.com/flex/mx.
June 18th, 2010 at 12:31 pm
why appear the error:
Can not be “” analysis for the component implementation.
Can not be “” analysis for the component implementation.
June 18th, 2010 at 1:11 pm
why appear the error:
Can not be “mx:UIComponent” analysis for the component implementation.
July 20th, 2010 at 6:19 am
You can use tag s:SpriteVisualElement to get the same result, too.And more easily.