Integrating Papervision3D into the Adobe Flash Builder Sparks containers architecture.

July 7th, 2009 by Slav

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 :

PV3D in Flex 4

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

8 Responses

  1. Sean Moore

    Pure awesomeness!! Great work!!!

  2. Dave Gamez

    Very good work !!!

  3. Daily Tweet Roundup for 2009-07-08 | Z3bb Blog

    […] – #Papervision3D integrated into the new #Flex 4 "Spark" component model – http://durej.com/?p=110 (via @tomkrcha @ryanstewart) […]

  4. Twitter Weekly Updates for 2009-07-13 at .swfgeek

    […] – Papervision3D integrated into the new Flex 4 "Spark" component model – http://durej.com/?p=110 (via @tomkrcha) […]

  5. Mark Simon

    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.

  6. xpf

    why appear the error:
    Can not be “” analysis for the component implementation.
    Can not be “” analysis for the component implementation.

  7. xpf

    why appear the error:
    Can not be “mx:UIComponent” analysis for the component implementation.

  8. RoYan

    You can use tag s:SpriteVisualElement to get the same result, too.And more easily.

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.