Adding a BasicView to a Flex UIComponent
While I would always encourage to separate your code into separate classes to follow best OOP practices, the example below will “get the job done”.
Since the Flex framework is based off UIComponents and you can’t directly add Sprites (or BasicViews) to a UIComponent, you have to dig into the UIComponents rawChildren (meaning Sprites) to add Papervision3D.
<?xml version="1.0" encoding="utf-8"?> <mx:Application width="640" height="480" xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="applicationComplete()"> <mx:Script> <![CDATA[ /* There are two similar methods: 1. using rawChildren 2. using $addChild with the mx_interal namespace Method #2 is commented out below */ // use namespace mx_internal; //method #2 import org.papervision3d.objects.primitives.Sphere; import org.papervision3d.view.BasicView; private function applicationComplete():void { var basicView:BasicView = new BasicView(); var sphere:Sphere = new Sphere(); basicView.scene.addChild(sphere); basicView.startRendering(); pv3dPanel.rawChildren.addChild(basicView); //method #1 // pv3dPanel.$addChild(basicView); //method #2 } ]]> </mx:Script> <mx:Panel id="pv3dPanel" title="Papervision3D Panel" width="640" height="480"/> </mx:Application>
-
Casey
-
Casey
-
Jianwen
-
camden_kid
-
camden_kid
-
Kyle Burke
-
John Lindquist
-
karul
Search
Recommended Books
Speaking at FITC Toronto
Recent Posts
- FDT Super Awesome March Deal
- haXe Tutorial
- AS3 Signals Tutorial
- Preferred Video Tutorial Resolution?
- TweenMax – Tweening a timeline (Advanced Tweening)
- Robotlegs + Flight + Union Platform
- Back in the saddle
- Eclipse Theme Designer Preview
- RobotLegs Hello World Video Tutorial
- 10 Things Every Senior Flash Developer Should Know
- Efflex – 3D Effects for Flex
- MorphController – Mighty Morphing Papervision3D
- End dump
- Test if a plane is within the view of the camera (aka testing if culled)
- Materials Reference
Recent Comments
- John Lindquist on ActionScript 3 – Model View Controller (MVC)
- Bruno Fonzi on FDT Super Awesome March Deal
- KD on ActionScript 3 – Model View Controller (MVC)
- BAM5 on haXe Tutorial
- AlexG on Finding 2D Coordinates of a DisplayObject3D
- Josh on ActionScript 3 – Model View Controller (MVC)
- martin everett on requests
- martin everett on requests
- lillacska on Dragging Spheres
- Guy Ritchie on MXML without the Flex framework
Categories
Archives
Preferred Video Tutorial Resolution
- 1024x768 (53%, 85 Votes)
- 1280x1024 (15%, 24 Votes)
- 1920x1080 (15%, 24 Votes)
- 800x600 (13%, 20 Votes)
- 480x320 (4%, 6 Votes)
- 640x480 (0%, 2 Votes)
Total Voters: 160

