Over 10 years of community discussion and knowledge are maintained here as a read-only archive.
package view { import org.papervision3d.cameras.CameraType; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.view.BasicView; import flash.events.Event; /** * @author davidfox */ public class WallScene extends BasicView { private var _cameraPoint : DisplayObject3D; private var _cubes : Array; public function WallScene() { super( 900, 700, true, false, CameraType.DEBUG); camera.focus= 300; camera.zoom= 10; camera.z= -3000; startRendering(); _cameraPoint = new DisplayObject3D(); _cameraPoint.z = -1000; } public function init(cubes : Array) : void { _cubes = new Array(); for (var i : int = 0; i < 8; i++) { var thisCube : WallCube = new WallCube(cubes[0]); thisCube.x = i * 110 - (3.5 * 110); thisCube.lookAt(_cameraPoint); scene.addChild(thisCube); _cubes.push(thisCube); } } override protected function onRenderTick( e : Event = null ):void { _cameraPoint.x = camera.x; _cameraPoint.y = camera.y; _cameraPoint.z = camera.z; for (var i : int = 0; i < _cubes.length; i++) { _cubes[i].lookAt(_cameraPoint); } super.onRenderTick( e ); } }}
package view { import org.puremvc.as3.multicore.interfaces.INotification; import org.puremvc.as3.multicore.patterns.mediator.Mediator; public class WallSceneMediator extends Mediator { public static const NAME : String = "WallSceneMediator"; public function WallSceneMediator(viewComponent : Object = null) { super(WallSceneMediator.NAME, viewComponent); } override public function listNotificationInterests() : Array { return [ApplicationFacade.CREATE_CUBES]; } override public function handleNotification(note : INotification) : void { switch( note.getName() ) { case ApplicationFacade.CREATE_CUBES : wallScene.init(note.getBody() as Array); break; default : break; } } public function get wallScene() : WallScene { return viewComponent as WallScene; } }}
If you are using Flex you can use the PMVC Console
Ok so I'm going to go down the uniquely named mediators route. However, where should I create those Mediators? I'm actually instantiating my WallCube's inside WallScene which doesn't have access to the facade. Can I somehow retrieve it inside there? Is that a correct way of doing things? If so, maybe I can create the mediator inside the actual WallCube class.
: Jason MacDonald August 11, 2009, 06:01:19 If you are using Flex you can use the PMVC ConsoleWhao, that looks amazing! Unfortunately I'm not using Flex though. Just Eclipse with the FDT plugin