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] 2
1  PureMVC Manifold / MultiCore Version / Re: Building Module-based PureMVC Multicore Projects with Ant on: February 11, 2011, 10:00:09
How funny just this this yesterday:

Here's an example of what I used:

http://snipplr.com/view/48821/ant-task-for-as-projects-with-flash-builder/

take special notice of "link-report" in mxmlc.  Your mods will need that to optimize.
2  Announcements and General Discussion / General Discussion / Re: Thoughts on Robotlegs on: August 03, 2010, 12:31:45
I've done work in both.

One of the major pros for robotlegs is the amount of less boiler plate code.

Robotlegs does not have a multicore version but there are some utilities for that. 

Puremvc would be considered the more mature framework. ( there's lots of nice utilities ).  Might also have the bigger community following.

I don't really like the pipes module (thought it was too hard to get working first time around), but Fabrications is great!

Also, I beleive robotlegs leaves a smaller footprint.

Theses are just the things that came to mind.
3  PureMVC Manifold / MultiCore Version / Re: Eclipse plugin for pureMVC on: November 11, 2009, 11:07:19
I was actually hoping to see some custom project files that would help you start coding with puremvc.  Maybe a quick key for "create new Mediator"  My java is not so good right now, but I'm hoping to one day get to this if no one else does it first.
4  PureMVC Manifold / MultiCore Version / Re: Papervision and MVC on: April 29, 2009, 10:13:35
I too would like to know how to best develop something like this.

My company and I just completed a project similar to this.  I love this framework and used the Alternativa Platform.  The issue with this is that all of the 3d engines out there are so closely tied to the stage.  I would like to find something out there better suited for the framework.

My solution was kind of messy but it worked for now.  I basically placed most of my 3d code in the main module class, which extends “PipeAwareModule.”  The Mediator that mediates that class can then register other mediators to mediate parts of the engine if you need to.

Anyway, like I said, don’t think this is the best solution but it worked for me.

5  Announcements and General Discussion / Architecture / Re: Using Proxies and Singletons... best practice question. on: March 27, 2009, 10:35:29
upon further exploring, I found that I was not properly removing my proxies in my dispose method.  This seems to have fixed my problems.
6  Announcements and General Discussion / Architecture / Re: Using Proxies and Singletons... best practice question. on: March 23, 2009, 09:32:51
Thanks Cliff, I'll make sure to take a look  ;D
7  Announcements and General Discussion / Architecture / Re: Using Proxies and Singletons... best practice question. on: March 20, 2009, 11:42:40
Hey, Thanks for taking the time to respond, and sorry for not responding fast enough. 

The Model doesn't really know about the view in this case.  It just keeps certain boolean varialbes that switch on and off, and dispatches events when they are changed to anybody who has wants to listen.  For example, when I want certain elements to disable, I'll change a variable in the model. 

In reality, this is my answer to not using pipes, because for some reason, even after I 'removedCore' something remained in memory.  Causing the application to give me an error when I sent a message through pipe and then tried to grab an instance of it again next time I loaded my module.  ( Don't know if this is a bug ).

Anyway, I think Joshua Ostrom ran into the same thing and narrowed it down to having to close the 'Tsplit' connection.  But I don't think I can refactor the code at this stage.  The code is in his Mortgage App pipe demo http://www.joshuaostrom.com/2008/06/17/pipe-demo-mortgage-app/.

So that's where I'm at, and was hoping I could get some advice from the pros.  If you think this is a oop no no, I'll refactor next time to implements Joshua's techniques or use Fabrications?  Thanks again for responding to this.
8  Announcements and General Discussion / Architecture / Using Proxies and Singletons... best practice question. on: March 17, 2009, 05:44:21
I have an application I'm creating right now that requires me to use a Singleton that houses data related to the state of a view component.  The view component resides in my shell application, and I need to be able to have loaded modules affect the state of that view component.  I'll do this by having the Singleton dispatch events when data is changed.

I find it easier to do this because I ran into problems trying to do this with pipes (closing connections), and I'm not ready to jump into Fabrications just yet.  It's also a lot less code.

My question is - Is this the best way to do it?  and ( if this sounds like a good directiong ) What type of data object is that?

9  PureMVC Manifold / Demos and Utils / Re: StartupManager - A PureMVC AS3 Utility on: June 16, 2008, 09:15:18
I'm probably just speaking for myself. My needs might be very unique but perhaps your right and I might be able to use StartupManager.

start and stop a load: outside, local to the client app proxy; is it critical that the overall monitor be able to do this?  what is the example case?

Lets say I'm trying to load two files of similar size that will take 20 seconds to complete.  The current manager will take the percentage to 50% at 10 seconds and then go to 100% at 20.  Seems two long a wait for no action to take place.  That's why a contentmanager that can initialize to calculate the totatlbytes of the two files and then give you an accurate percentage rate before you actually start loading is crucial for sites that need to load a video or swf of that caliber.

As far as the rest of it goes, you're right...

Although, I am going to try something new with what i'm experimenting with right now.  The manager I'm building has a public load method that accepts a request object which contain a callback function and a list of assets to load.  Once loaded I'm going to try and send back an object with a keys tied to the asset it loaded.  for example:

:
key = "my.jpg"
object[key] = bitmap

Hope I'm making sense.  Anyway.  I'll see how this works for me and once done, I'll see if I can do the same with the current StartupMonitor.  If I can live with just using the StartupMonitor I'll post my findings.
10  PureMVC Manifold / Demos and Utils / Re: StartupManager - A PureMVC AS3 Utility on: June 16, 2008, 10:00:40
I guess I'll experiment with both routes :)
11  PureMVC Manifold / Demos and Utils / Re: StartupManager - A PureMVC AS3 Utility on: June 13, 2008, 11:09:10
perhaps a little elaboration on why you don't think startup manager is right for the job

Maybe it's just the way I've grown to use it.  For me, it's the step before I setup my view, and there on end, call it when ever the view changes something in the model.

The utility that I'm proposing gives you the ability to load more "viewComponents."  You would have the ability to start and stop a load, load multipy files. Maybe even have it be aware of what type of file it's loading.  Factory pattern comes to mind... something with keys so you can refrence an image by name, if it finds it return Bitmap, if not load and return.

And just to simplify things, have startupmanager be a utility used for the model layer, and this new one for the view. 

If you disagree, let me know why.  I want to learn...

Mold me Cliff  ;D  into a mvc genius like you
12  PureMVC Manifold / Demos and Utils / Re: StartupManager - A PureMVC AS3 Utility on: June 12, 2008, 10:48:38
 :)

Hey, it's been a long time since I've posted anything on this forum. I apologize if I'm just reiterating something that's already been said.

I just have a quick question..

Looking through this topic I've noticed some talk of asset managing. 
I love this manager.  It's great for setting up your backend, streaming, and xml connections at startup but if I want to load up another swf at runtime I feel that this manager shouldn't be in charge of it.  It's great right now!

I do however need a manager for loading one or multiple swfs.  I realize this tool is probably more geared toward a flash site where you don't need all the pages loaded at startup, just the ones the user wants to see.  It would be great if you could make a list of swfs then, have as3 use the URLStream class to just find the totalbytes of everything in your list(without loading), then begin loading with a proper progress event handler that gives you an accurate percentage of all the swf's, flv's, or images in the list.

I know justSteve has been working on something similar.  Should this constitute another utility?  Anybody else see a need for this?  Am I talking out of my butt?
13  Announcements and General Discussion / General Discussion / Re: first project with pureMVC on: February 07, 2008, 10:17:57
You don't have to change anything.  It's not even perfect.  Just finished it today and I thought I would share.  ;)  I needed something quick so this is what I came up with.  I don't even take ownership.  Like I said, this code was going in a different direction and is probably not the best way to go.
14  Announcements and General Discussion / General Discussion / Re: first project with pureMVC on: February 07, 2008, 01:35:13
Ok, I figured something out.  This is what I came up with for timing out.  I might be going in a different direction so feel free to pull me in.

I didn't want to get to far from where Philip was heading but I did want to keep things in reach of the ApplicationFacade so I could send notifications.

So here's what I did different.  Seeing as all these examples have the proxies using the same method ( loading, onComplete, etc).  I created the StartupResourceProxy which extends Proxy. All proxies that now work with the StartupMonitorProxy extend StartupResourceProxy in my project.  I also moved Philips StartupResource class in here.

Here's the code.
:
package org.puremvc.utilities.startupmanager
{
import com....ApplicationFacade;

import flash.events.TimerEvent;
import flash.utils.Timer;

import org.puremvc.interfaces.IProxy;
import org.puremvc.patterns.proxy.Proxy;

public class StartupResourceProxy extends Proxy implements IProxy
{
private static const EMPTY :String = 'empty';
        private static const LOADING :String = 'loading';
        private static const LOADED :String = 'loaded';
        private static const TIMED_OUT:String = 'timed_out';

private var status :String;

private var _timeout:int;
private var timer:Timer;

// StartupResources, pre-requisites for this resource, if any.
// These pre-requisites must be loaded before this resource can be loaded.
private var _requires :Array;

public function StartupResourceProxy(proxyName:String=null, data:Object=null)
{
super(proxyName, data);

this.status = EMPTY;
this.requires = new Array();
}

public function setStatusToLoading() :void
{
    status = LOADING;
   
    if(this._timeout != 0)
    startTimer();
}

public function setStatusToLoaded() :void
{
    status = LOADED;
    if(this._timeout != 0)
    timer.stop();
}

public function setStatusToTimedOut() :void
{
status = TIMED_OUT;
}

public function isLoaded() :Boolean
{
    return status == LOADED;
}

public function isTimedOut() :Boolean
{
return status == TIMED_OUT;
}

public function set requires( resources :Array ) :void
{
    _requires = resources;
}

public function get requires() :Array
{
    return _requires;
}

public function isOkToLoad() :Boolean
{
    if ( status != EMPTY ) return false;
    for( var i:int =0; i < requires.length; i++) {
    var r:StartupResourceProxy = requires[i] as StartupResourceProxy;
        if ( !r.isLoaded())
        return false;
    }
    return true;
}

public function set timeout(value:int):void
{
this._timeout = value;
}

private function startTimer():void
{
    timer = new Timer(this._timeout*1000, 1);
        timer.addEventListener(TimerEvent.TIMER, timedOut);
        timer.start();
}

private function timedOut(e:TimerEvent):void
{
this.sendNotification( ApplicationFacade.STARTUP_RESOURCE_TIMEDOUT, this.getProxyName());
}
}
}
and here's the interface you can implement:
:
package org.puremvc.utilities.startupmanager
{
import flash.events.Event;

public interface IStartupResourceProxy
{
/**
* Get the Proxy name
*
* @return the Proxy instance name
*/
function getProxyName():String;

function onComplete(e:Event):void;
function load():void;
}
}

I've added some code to Philips StartupResouce class which handles the timer event.  If the resource times out before it's finished loading, it notifies the StartupResourceCommand as follows.

:
package com....controller
{
import com....ApplicationFacade;
import com....model.StartupMonitorProxy;

import org.puremvc.interfaces.ICommand;
import org.puremvc.interfaces.INotification;
import org.puremvc.patterns.command.SimpleCommand;

public class StartupResourceTimedOutCommand extends SimpleCommand implements ICommand
{
override public function execute(notification:INotification):void
{
( facade.retrieveProxy( StartupMonitorProxy.NAME ) as StartupMonitorProxy).
    resourceTimedOut( notification.getBody() as String );
}

}
}

This lets the monitor know what just timed out.  I added a few things to the monitor to work with the resources that have timed out. It primarily just adds the resource to a list and allows the system to keep going if it doesn't finish loading.

Here's the code:
:
package com....model
{

import com....ApplicationFacade;

import org.puremvc.interfaces.*;
import org.puremvc.patterns.proxy.Proxy;
import org.puremvc.utilities.startupmanager.StartupResourceProxy;


    public class StartupMonitorProxy extends Proxy implements IProxy
    {
public static const NAME:String = "StartupMonitorProxy";
// array listing all the resources to be loaded
private var resourceList:Array;
// array listing all the resources that timed out.
private var timedOutResourcesList:Array;
// number of loaded resources
private var loadedResources:int = 0;

public function StartupMonitorProxy ( data:Object = null )
        {
            super ( NAME, data );
this.resourceList = new Array();
this.timedOutResourcesList = new Array();
        }


/**
*Add a resource to be loaded

* @param r
*
*/
public function addResource( r :StartupResourceProxy, timeout:int=0 ):void
{
this.resourceList.push( r );

//If timeout included, add a timer;
if(timeout!=0)
r.timeout = timeout;
}

/**
         * Start/Continue to load all resources
         */
public function loadResources():void
{
for( var i:int = 0; i < this.resourceList.length; i++)
{
var r:StartupResourceProxy = this.resourceList[i] as StartupResourceProxy;
if ( r.isOkToLoad() )
{
var proxy:* = facade.retrieveProxy( r.getProxyName() ) as Proxy;
r.setStatusToLoading();
proxy.load();
}
}
}

/**
*The resource timed out, adds proxy to a list of any timed out proxies.

* @param proxyName
*
*/
public function resourceTimedOut(proxyName :String ):void
{

for( var i:int = 0; i < this.resourceList.length; i++)
{
var r:StartupResourceProxy = this.resourceList[i] as StartupResourceProxy;
if ( r.getProxyName() == proxyName )
{
r.setStatusToTimedOut();
timedOutResourcesList.push(r.getProxyName());
this.loadedResources++;

// if not all loaded, continue load.
if ( !allResourcesLoaded() )
{
this.loadResources();
}
break;
}
}
}

/**
         * The resource is loaded, update the state and check if the loading process is completed
*
         * @param name proxy name
         */
public function resourceLoaded( proxyName :String ):void
{
for( var i:int = 0; i < this.resourceList.length; i++)
{
var r:StartupResourceProxy = this.resourceList[i] as StartupResourceProxy;
if ( r.getProxyName() == proxyName )
{
r.setStatusToLoaded();
this.loadedResources++;

// send the notification for update the progress bar
//this.sendNotification( ApplicationFacade.LOADING_STEP, this.resourceList.length / this.loadedReources * 100 );

// if not all loaded, continue load.
if ( !allResourcesLoaded() )
{
this.loadResources();
}
break;
}
}

}

/**
         * Check if the loading process is completed
*
         * @return boolean process is completed
         */
private function allResourcesLoaded():Boolean
{
for( var i:int = 0; i < this.resourceList.length; i++)
{
var r:StartupResourceProxy = this.resourceList[i] as StartupResourceProxy;
if ( !r.isLoaded() && !r.isTimedOut() )
{
return false;
}
}

this.sendNotification( ApplicationFacade.LOADING_COMPLETE );
return true;
}

public function timeOutList():Array
{
return timedOutResourcesList;
}
}
}

And here's the command that starts it all up.

:
package com....controller
{

public class ModelPrepCommand extends SimpleCommand implements ICommand
{

override public function execute( note:INotification ):void
{
/* ... register monitor proxies ... */
facade.registerProxy( new StartupMonitorProxy() );
    var monitor:StartupMonitorProxy = facade.retrieveProxy( StartupMonitorProxy.NAME ) as StartupMonitorProxy;
   
            /* ... register other proxies ... */
            facade.registerProxy( new ProxyA() );
            facade.registerProxy( new ProxyB() );
           
            var rA:StartupResourceProxy = facade.retrieveProxy( ProxyA.NAME ) as StartupResourceProxy;
            var rB:StartupResourceProxy = facade.retrieveProxy( ProxyB.NAME ) as StartupResourceProxy;

monitor.addResource( rA, 10);
monitor.addResource( rB, 10 );

          rA.requires = [ rB ];
           
          monitor.loadResources();
}
}
}

Sorry for the long post.  This seems to work for me and I like how it hide most of the code by just extending the StartupResourceProxy. I tought about getting the retry policies going but wanted to get some feed back about this first.  Let me know if this helps anybody. PUREMVC RULES!!  ;D
15  Announcements and General Discussion / General Discussion / Re: first project with pureMVC on: February 04, 2008, 11:26:42
So over the weekend I started to add the Time out functionality.  I have a site that did not load completely because a streaming server somewhere was turned off.  Needless to say, people were upset. :)

My delima is that until now, there was no flash spicific code in the framework.  I thought that best place to put the timer was in Phillip's StartupResource class, but this brings up other things like, "what's going to be listening for timer event?"  Does this really matter now that the framework is being ported to all these other languages and this version is more specifically the as3 version?

Probablly being the biggest newbe of the bunch, I'd like to know what's best practice, and if any body has any suggestions on how to implement the timeout functionallity.  The more I think about it, the more important it is to have this on a site that loads in data from other servers.
Pages: [1] 2