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 / Re: Keeping track of data associated with display objects on: August 12, 2009, 04:57:13
Ah Cliff, you are THE MAN!
That's a great explanation and really makes sense in my context.  I think my problem was that I was thinking that I should be using FLASH events as little as possible but yes, there is obviously still quite a lot of things they should be doing within the PureMVC framework.

Can't believe I'm only just picking up PureMVC now.  It's awesome!  Separating the functionality of view components into mediators etc really does make my view components reusable in other projects.  Before I was sort of reusing stuff but it would always mean stripping out functionality from their classes, updating the functionality a bit etc.  Now I just copy the view item across and update the mediator!  Nice ;)

Anyways, thanks again for your help Cliff, you're a great ambassador for an opensource project but unfortunately, I will probably be back with more questions as I delve farther into things! :(
3  Announcements and General Discussion / Architecture / Re: Keeping track of data associated with display objects on: August 11, 2009, 07:31:28
If you are using Flex you can use the PMVC Console
Whao, that looks amazing!  Unfortunately I'm not using Flex though.  Just Eclipse with the FDT plugin :(
4  Announcements and General Discussion / Architecture / Re: Keeping track of data associated with display objects on: August 11, 2009, 02:29:06
Also, one other thing about how easy it is to share projects with other developers using PureMVC...

Imagine we have a notification being sent from somewhere but it HASN'T had a command created for it (which appears to be normal practice looking at HelloSprite) but we are just listening for that notification in a mediator... How is it possible to keep track of who's listening for what?

If I take on a huge project from somebody else and some action is happening based upon a notification being sent, surely it would be difficult to track down the individual classes and their mediators who are actually acting upon them.

Is it just a matter of "name your display objects and their mediators well so by looking at the app in action, you can see what is changing and then track down the DO's class"?
5  Announcements and General Discussion / Architecture / Re: Keeping track of data associated with display objects on: August 10, 2009, 03:07:22
Ahaaaa...  I see.  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.  If not, do I have to start creating the cubes inside WallScene's mediator?  I thought that making the cubes would have to take place inside WallScene as it's part of building the view...
6  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]