Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Show Posts

| * |

  Show Posts
Pages: [1]
1  Announcements and General Discussion / Architecture / Creating Methods To Retrieve Data From Proxies on: August 14, 2009, 08:51:22
Hi there,
Ok so after loading in my XML, I create a bunch of Value Objects, insert them into an array and then register a proxy which passes in that array.

My question is, how and where do I write code to interact with that proxy?

Basically, each value object will have an id and I would like to write a function that takes an ID as a parameter, then loops through the array of value objects and if one of their IDs matches the passed parameter, returns that value object.

Before PureMVC, I would have my array stored in a singleton somewhere and then I would write static functions to deal with this kind of thing.  However, I can't seem to find a way to first retrieve the proxy and then start using my own functions written inside that proxy.  For that matter, should I actually be writing my own functions INSIDE a proxy for these sorts of things?  I will want to be doing this kind of searching functionality quite a lot throughout my site.

2  Announcements and General Discussion / Architecture / Keeping track of data associated with display objects on: August 10, 2009, 12:29:10
Hi there,
I'm a first time board poster and currently working on my first project using PureMVC!  It's slightly intimidating but I'm taking it slowly so I don't accidentally use any of my non-PureMVC based habits.

Anyways, I have a couple of questions if you can spare a moment...

Basically, I have a Papervision3D scene (called WallScene)...

:
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 );
}
}
}

Now most of this is just using test data.  What I want to concentrate on is where I'm adding instances of WallCube.as.  As far as I understand, I shouldn't be accessing (even if I CAN!) the facade or any proxies inside the above class.  So, I created a Mediator...

:
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;
}
}
}

Now during my startup, when I've finished collating my data, I do a sendNotification(ApplicationFacade.CREATE_CUBES, arrayOfCubeVOs).

How am I doing so far?

Anyways, WallCube simply extends the Cube Papervision primitive. 

Now, here's the question... I'm going to want to store data about each of these cubes and they'll have to be able to find out/accept information about each other.  For example, clicking on one will make another one spin etc.

I was thinking of creating a proxy to store an array of WallCube instances but where would I do that?  The cubes themselves are created in the WallScene class and surely it shouldn't be accessing the facade to start storing proxies...

If you made it this far, thanks so much for taking the time to read!  Any help you could give would be brilliant.  I'm just starting out but am seeing the advantages of PureMVC already!
Pages: [1]