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>
-
Affordable web hosting plans
-
Casey
-
Casey
-
Jianwen
-
camden_kid
-
camden_kid
-
Kyle Burke
-
John Lindquist
-
karul
Search
Recommended Books
Speaking at FITC Toronto
Recent Posts
- Moving to johnlindquist.com
- AsyncCommand with Robotlegs, Signals, Flight, MinimalComps
- Search Widget – Robotlegs, Signals, Flight, Minimal Comps, Yahoo Astra
- 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
Recent Comments
- software akuntansi terbaik on Back in the saddle
- loan rates on Augmented Reality – Recursive Webcam
- loan rates on Looking around the inside of a Sphere
- reverse phone lookup on Looking around the inside of a Sphere
- Oidhreachta on The Spotlight Effect (Dimming the unselected)
- Hosting company on archive
- aanbae on Back in the saddle
- Domain registration on Looking around the inside of a Sphere
- website designing company on Looking around the inside of a Sphere
- Honda Motor on Augmented Reality – Recursive Webcam
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

