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] 3
16  PureMVC Manifold / Bug Report / Re: Unable to Read the Project File on: November 16, 2009, 07:33:31
Thanks Austin, this one converted fine to VS 2008.
17  PureMVC Manifold / Standard Version / Re: Best Practices for Sending Messages to Mediators from Views on: August 21, 2009, 12:06:57
Here's what I intend to do.

In index.php:

:
$protoManager = new PrototyperManager();

if (sizeof($_POST)>0) {
    $protoManager->sendPost($_POST);
}

In the same package as ApplicationFacade.php:

:
<?php
/**
 * PrototyperManager
 * PureMVC CRUD for Flex Prototyper System
 *
 * @author Mike Britton :: mike@mikebritton.com
 * 
 * Created on Aug 20, 2009
 */

require_once $_SESSION['relpath'].'/ApplicationFacade.php';

/**
 * PrototyperManager base class.  The index starts an
 * instance of the object to start the application
 * view calling the <code>startView()</code> method.
 */
class PrototyperManager
{
public function __construct()
{
   //
}

/**
 * Starts the PureMVC framework passing in variables
 * from the index.php
 */
public function startView$filename$pageName )
{
$facade ApplicationFacade::getInstance();
$facade->startUp$filename$pageName );
}

public function sendPost($formPost)
{
   switch($formPost["type"]) {
       case "login":
           
       break;
   }
}
}

?>


18  PureMVC Manifold / Standard Version / Best Practices for Sending Messages to Mediators from Views on: August 20, 2009, 01:45:15
In the the AS3 port, my views have event constants defined and I handle them in my Mediators, which then send Notifications.

In the PHP port, I have a Manager class that looks for $_GET or $_POST and uses the Facade to send Notifications.  I'd rather communicate back to my views' Mediators without going through the facade.

Just wondering what you all are doing.
19  PureMVC Manifold / Standard Version / Re: Registering Mediators Dynamically on: November 20, 2008, 11:37:54
Uh....

Because I didn't think of that.  Maybe I should avoid coding when I haven't had my coffee.

Thanks Cliff!
20  PureMVC Manifold / Standard Version / Registering Mediators Dynamically on: November 20, 2008, 06:07:05
I have an app that has two modes, "default" and "custom".  Default mode means views use a standard set of components; custom mode means views have been customized and should load images for their UI.

Because of this, my views differ significantly enough to warrant creating a mediator for each.  The alternative would introduce a lot of messy conditional logic to the views, which is something I want to keep at a minimum.

So here goes: I have a command that registers these mediators based on boolean flags set in my proxies.  These booleans tell the app whether certain views are "custom" or "default".  How do I refer to the base app, where the views have been instantiated, from my command?

One approach is to store a reference to the main application on the facade, and fire a method on the facade when I'm ready to set the mediators dynamically.

In ApplicationFacade:

:
public function startup( app:VODPlayer ):void
{
this.app = app;
sendNotification( STARTUP, app );
}

public function get app():VODPlayer { return __app; }
public function set app(value:VODPlayer):void { __app = value; }

In the Command:

:
var app:VODPlayer = ApplicationFacade(facade).app;

This doesn't feel like a good technique.  Has anyone come up something more elegant?  Am I missing something simple and obvious?
21  PureMVC Manifold / MultiCore Version / Re: Having a Hard Time with Pipes on: June 26, 2008, 10:45:59
More struggles with Pipes, still no success.  I'm posting here so when I solve the problem myself, I can post the solution.

My ShellJunctionMediator is registering pipes:

:
override public function onRegister():void
{
trace("ShellJunctionMediator::onRegister");

junction.registerPipe( PipeAwareModule.APP_TO_MODULE_PIPE,  Junction.OUTPUT, new TeeSplit() );
junction.registerPipe( PipeAwareModule.MODULE_TO_APP_PIPE,  Junction.INPUT, new TeeMerge() );
junction.addPipeListener( PipeAwareModule.MODULE_TO_APP_PIPE, this, handlePipeMessage );
}

When my module loads, ShellJunctionMediator connects it:

:
public function connectModule( module:AppAModule ):void
{
//Create the pipe
var moduleToApp:Pipe = new Pipe();
module.acceptOutputPipe(PipeAwareModule.MODULE_TO_APP_PIPE, moduleToApp);

//Connect the pipe to our app
var appIn:TeeMerge = junction.retrievePipe(PipeAwareModule.MODULE_TO_APP_PIPE) as TeeMerge;
appIn.connectInput(moduleToApp);

//Create the pipe
var appToModule:Pipe = new Pipe();
module.acceptInputPipe(PipeAwareModule.APP_TO_MODULE_PIPE, appToModule);

//Connect the pipe to our module
var appOut:IPipeFitting = junction.retrievePipe(PipeAwareModule.APP_TO_MODULE_PIPE) as IPipeFitting;
appOut.connect(appToModule);

}

Finally, after all this happens, I try to send a message from Shell to the module when the Shell is clicked:

:
case ApplicationFacade.SHELL_SELECTED:
if (junction.hasOutputPipe(PipeAwareModule.APP_TO_MODULE_PIPE)) {
var myMessage:Message = new Message(PipeAwareModule.STDOUT,new Object(), new Notification(MMEventNames.BASIC_MESSAGE,note.getBody(),"COOL"))
junction.sendMessage(PipeAwareModule.APP_TO_MODULE_PIPE, myMessage);
}
break;


This results in an error:

:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at org.puremvc.as3.multicore.utilities.pipes.plumbing::Pipe/write()[C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\pipes_boilerplate\src\org\puremvc\as3\multicore\utilities\pipes\plumbing\Pipe.as:77]
at org.puremvc.as3.multicore.utilities.pipes.plumbing::TeeSplit/write()[C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\pipes_boilerplate\src\org\puremvc\as3\multicore\utilities\pipes\plumbing\TeeSplit.as:77]
at org.puremvc.as3.multicore.utilities.pipes.plumbing::Junction/sendMessage()[C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\pipes_boilerplate\src\org\puremvc\as3\multicore\utilities\pipes\plumbing\Junction.as:194]
at com.britton.apps.pipesboilerplate.modules.shell.view.mediator::ShellJunctionMediator/handleNotification()[C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\pipes_boilerplate\src\com\britton\apps\pipesboilerplate\modules\shell\view\mediator\ShellJunctionMediator.as:75]

Apparently the Pipe output is null. 

22  PureMVC Manifold / MultiCore Version / Re: Having a Hard Time with Pipes on: June 25, 2008, 12:35:45
In JunctionPrepCommand, after registering my Mediators and adding the module to Shell, I'm sending a MODULES_LOADED Notification:

:
override public function execute( note:INotification ):void
{
var app:Shell = note.getBody() as Shell;

facade.registerMediator( new ApplicationMediator( app ) );
facade.registerMediator( new AppAModuleMediator() );

var amm:AppAModuleMediator = facade.retrieveMediator(AppAModuleMediator.NAME) as AppAModuleMediator;

app.addAppA(amm.appa);

facade.registerMediator( new ShellJunctionMediator() );

sendNotification( ApplicationFacade.MODULES_LOADED, app.appa );
}


My ShellJunctionMediator receives this Notification, creates the Pipes and connects them.

:
case ApplicationFacade.MODULES_LOADED:
var appam:AppAModule = note.getBody() as AppAModule;
connectModule( appam );
junction.sendMessage(PipeAwareModule.APP_TO_MODULE_PIPE,new Message(PipeAwareModule.STDOUT,null,5));
break;


Here's the function that connects the passed module:

:
public function connectModule( module:AppAModule ):void
{
//Create the pipe
var moduleToApp:Pipe = new Pipe();
module.acceptOutputPipe(PipeAwareModule.MODULE_TO_APP_PIPE, moduleToApp);
//Connect the pipe to our app
var appIn:TeeMerge = junction.retrievePipe(PipeAwareModule.MODULE_TO_APP_PIPE) as TeeMerge;
appIn.connectInput(moduleToApp);

//Create the pipe
var appToModule:Pipe = new Pipe();
module.acceptInputPipe(PipeAwareModule.APP_TO_MODULE_PIPE, appToModule);
//Connect the pipe to our module
var appOut:TeeSplit = junction.retrievePipe(PipeAwareModule.APP_TO_MODULE_PIPE) as TeeSplit;
appOut.connect(appToModule);

}


When compiled, this app should send a Message to AppAJunctionMediator, which should then respond to the app with another Message.

It's taken me a week to get to this point and I'm sure whatever mistake I'm making is a simple one.  Thanks in advance -- the code in the link above will compile.




23  PureMVC Manifold / MultiCore Version / Re: Having a Hard Time with Pipes on: June 25, 2008, 07:49:36
I'm still trying to get a basic, boilerplate example working.  Here it is: http://www.mikebritton.com/downloads/pipes_boilerplate.rar

This is a non-Flex, AS3 example.  Main.as should be set as the default application.  I want to establish two-way communication between my Shell and a module, AppAModule.  If anyone could take a look and let me know what I'm doing wrong, I'd sure appreciate it.
24  PureMVC Manifold / MultiCore Version / Re: Having a Hard Time with Pipes on: June 14, 2008, 10:58:23
The Unit Tests are more helpful.  I also ran across a nice chart showing a basic implementation:

25  PureMVC Manifold / MultiCore Version / Having a Hard Time with Pipes on: June 09, 2008, 11:45:42
I don't know what it is, but I can't figure out how to get a simple message to a module from my shell and vice-versa.  I'm working in Flash AS3 only, no Flex.  I'd post code here, but last time I did, the post was removed.  Can anyone give me a step-by-step process?

I must be in a rut because here I am a week later without a clear handle on this.

The demo is great, but as I try to port my architecture to an implementation with Pipes, the complexity of tracing through the demo to decide how to move forward is not conducive to good learning.
26  PureMVC Manifold / MultiCore Version / Flash only Demo? on: June 04, 2008, 11:33:14
Here's my problem in detail, so pardon the massive code dump.  Hopefully my issue can be solved easily; the main issue is my attempt to rearchitect an existing application with Pipes before writing a simple boilerplate :-)

I have a Shell MovieClip that kicks it all off.
:
package
{
import com.multicastmedia.shell.ApplicationFacade;
import flash.display.DisplayObject;
import flash.display.MovieClip;

public class Shell extends MovieClip
{
public static const NAME:String = "Shell";

private var facade:ApplicationFacade = ApplicationFacade.getInstance( NAME );

public function Shell():void
{
facade.startup( this );
}

public function addLivePlayer(livePlayer:DisplayObject):void
{
addChild(livePlayer);
}

public function addSlides(slides:DisplayObject):void
{
addChild(slides);
}

public function removeLivePlayer(livePlayer:DisplayObject):void
{
removeChild(livePlayer);
}

public function removeSlides(slides:DisplayObject):void
{
removeChild(slides);
}
}
}

Picture three modules, a live video player, a slide display, and shell.  My Shell's ApplicationFacade:

:
package com.multicastmedia.shell
{

    import org.puremvc.as3.multicore.patterns.facade.Facade;
    import com.multicastmedia.shell.controller.StartupCommand;

public class ApplicationFacade extends Facade
{
// Notification constants
        public static const STARTUP:String                  = 'startup';
        public static const CONNECT_SHELL_TO_LIVEPLAYER:String = 'connectshelltoliveplayer';
        public static const CONNECT_SHELL_TO_LIVESLIDES:String = 'connectshelltoliveslides';
        public static const CONNECT_MODULE_TO_LIVEPLAYER:String = 'connectmoduletoliveplayer';
        public static const CONNECT_MODULE_TO_SLIDES:String = 'connectmoduletoslides';
        public static const CONNECT_MODULE_TO_SHELL:String = 'connectmoduletoshell';

        public function ApplicationFacade( key:String )
        {
            super(key);   
        }

        public static function getInstance( key:String ):ApplicationFacade
        {
            if ( instanceMap[ key ] == null ) instanceMap[ key ] = new ApplicationFacade( key );
            return instanceMap[ key ] as ApplicationFacade;
        }
       
        override protected function initializeController( ) : void
        {
            super.initializeController();           
            registerCommand( STARTUP, StartupCommand );
        }
       
        /**
         * Application startup
         *
         * @param app a reference to the application component
         */ 
        public function startup( app:Shell ):void
        {
            sendNotification( STARTUP, app );
        }
}
}


My Shell's StartupCommand executes:

:
package com.multicastmedia.shell.controller
{
import com.multicastmedia.shell.view.ShellJunctionMediator;
import com.multicastmedia.shell.view.ApplicationMediator;
import com.multicastmedia.shell.view.LivePlayerModuleMediator;
import com.multicastmedia.shell.view.SlideModuleMediator;
import com.multicastmedia.shell.ApplicationFacade;
import fl.motion.SimpleEase;

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

import org.osflash.thunderbolt.Logger;

public class StartupCommand extends SimpleCommand implements ICommand
{

override public function execute( note:INotification ):void
{
Logger.debug("StartupCommand:execute");

facade.registerMediator(new LivePlayerModuleMediator());
facade.registerMediator(new SlideModuleMediator());
facade.registerMediator(new ShellJunctionMediator());

var app:Shell = note.getBody() as Shell;
facade.registerMediator(new ApplicationMediator( app ));

sendNotification(ApplicationFacade.CONNECT_SHELL_TO_LIVEPLAYER);
}
}
}

The first mediator, LivePlayerModuleMediator, registered is really the only one related to this issue; when I understand why this is erroring out, I'll be able to fix for all modules.  So, I register this mediator, which looks like this:

:
package com.multicastmedia.shell.view
{
import org.puremvc.as3.multicore.interfaces.INotification;
import org.puremvc.as3.multicore.patterns.mediator.Mediator;
import org.puremvc.as3.multicore.utilities.pipes.plumbing.Pipe;
    import org.puremvc.as3.multicore.utilities.pipes.plumbing.TeeMerge;
    import org.puremvc.as3.multicore.utilities.pipes.plumbing.Junction;
    import org.puremvc.as3.multicore.utilities.pipes.interfaces.IPipeFitting;

import com.multicastmedia.common.IPipeAware;
import com.multicastmedia.common.JunctionMediator;
import com.multicastmedia.apps.live.LivePlayerModule;
import com.multicastmedia.shell.ApplicationFacade;

import org.osflash.thunderbolt.Logger;

public class LivePlayerModuleMediator extends Mediator
{
        public static const NAME:String = 'LivePlayerModuleMediator';
       
        public function LivePlayerModuleMediator()
        {
            super(NAME, new LivePlayerModule());
        }

        /**
         * LivePlayerModule related Notification list.
         */
        override public function listNotificationInterests():Array
        {
            return [ ApplicationFacade.CONNECT_SHELL_TO_LIVEPLAYER
                   ];   
        }
       
        /**
         * Handle LivePlayerModule related Notifications.
         *
         * Connecting modules and the Shell to the LivePlayerModule.
         */
        override public function handleNotification( note:INotification ):void
        {
            switch( note.getName() )
            {
                case  ApplicationFacade.CONNECT_SHELL_TO_LIVEPLAYER:
Logger.debug("CONNECT_SHELL_TO_LIVEPLAYER");
                    var module:IPipeAware = note.getBody() as IPipeAware;
                    var pipe:Pipe = new Pipe();
                    module.acceptOutputPipe(JunctionMediator.STDLOG,pipe);
                    livePlayer.acceptInputPipe(JunctionMediator.STDIN,pipe);
                break;
            }
        }
       
        /**
         * The Logger Module.
         */
        private function get livePlayer():LivePlayerModule
        {
            return viewComponent as LivePlayerModule;
        }
}
}

My LivePlayerFacade is instantiated and started.  It looks like this:

:
package com.multicastmedia.apps.live.liveplayer
{
import com.multicastmedia.apps.live.liveplayer.model.vo.ConfigVO;
import com.multicastmedia.apps.live.LivePlayerModule;
import org.puremvc.as3.multicore.interfaces.IFacade;
import org.puremvc.as3.multicore.patterns.facade.Facade;
import com.multicastmedia.apps.live.liveplayer.controller.StartupCommand;
import com.multicastmedia.apps.live.liveplayer.controller.GetLiveEventCommand;
import com.multicastmedia.apps.live.liveplayer.controller.LiveConnectionCommand;
import com.multicastmedia.apps.live.liveplayer.controller.LiveStreamControlCommand;
import com.multicastmedia.apps.live.liveplayer.controller.SharedObjectCommand;
import com.multicastmedia.apps.live.liveplayer.controller.PollForSlideCommand;
import org.osflash.thunderbolt.Logger;

import flash.display.StageDisplayState;
import flash.events.FullScreenEvent;

public class LivePlayerFacade extends Facade implements IFacade
{

// Notification name constants only
        public static const STARTUP:String = "startup";
        public static const CONFIG_LOADED:String = "config_loaded";
public static const GET_EVENT_INFO:String = "get_event_info";
public static const GET_SETTINGS:String = "get_settings";
public static const SETTINGS_RETURNED:String = "settings_returned";
public static const EVENT_LOADED:String = "event_loaded";
public static const EVENT_COMPLETE:String = "event_complete";
public static const CONNECT:String = "connect";
public static const CONNECTED:String = "connected";
public static const CONNECTION_FAILED:String = "connection_failed";
public static const POLL_LIVE_EVENT:String = "poll_live_event";
public static const POLL_DURATION_COMPLETE:String = "poll_duration_complete";
public static const POLL_COMPLETE:String = "poll_complete";
public static const POLL_DURATION:String = "poll_duration";
public static const POLL_FOR_SLIDE:String = "poll_for_slide";
public static const POLL_SLIDE_RETURNED:String = "poll_slide_returned";
public static const COUNTDOWN_COMPLETE:String = "countdown_complete";
public static const START_COUNTDOWN:String = "start_countdown";
public static const START_PREROLL:String = "start_preroll";
public static const START_POSTROLL:String = "start_postroll";
public static const TIME:String = "time";
public static const BUFFER_FULL:String = "buffer_full";
public static const DESTROY_NETSTREAM:String = "destroy_netstream";
public static const PAUSE_LIVE_STREAM:String = "pause_live_stream";
public static const STOP_LIVE_STREAM:String = "stop_live_stream";
public static const RESUME_LIVE_STREAM:String = "resume_live_stream";
public static const TOGGLE_FULLSCREEN:String = "toggle_fullscreen";
public static const ADJUST_VOLUME:String = "adjust_volume";
public static const ADJUST_PLAYER_SCALE:String = "adjust_player_scale";

// Failures
public static const EVENT_FAILED:String = "event_failed";
public static const GENERAL_FAILURE:String = "general_failure";

public function LivePlayerFacade( key:String ):void
{
super(key);
}

public static function getInstance( key:String ):LivePlayerFacade
        {
            if ( instanceMap[ key ] == null ) instanceMap[ key ] = new LivePlayerFacade( key );
            return instanceMap[ key ] as LivePlayerFacade;
        }

/**
* Map all Commands to Notifications here
*/
        override protected function initializeController( ):void
        {
            super.initializeController(); 

            registerCommand( STARTUP, StartupCommand );
            registerCommand( GET_EVENT_INFO, GetLiveEventCommand );
            registerCommand( GET_SETTINGS, SharedObjectCommand );
registerCommand( CONNECT, LiveConnectionCommand );
registerCommand( POLL_LIVE_EVENT, GetLiveEventCommand );
registerCommand( PAUSE_LIVE_STREAM, LiveStreamControlCommand );
registerCommand( RESUME_LIVE_STREAM, LiveStreamControlCommand );
registerCommand( STOP_LIVE_STREAM, LiveStreamControlCommand );
registerCommand( ADJUST_VOLUME, LiveStreamControlCommand );
        }

        public function startup( app:LivePlayerModule ):void
        {
Logger.debug("LivePlayerFacade::startup");
            sendNotification( STARTUP, app );
        }
}
}


The command it executes is a MacroCommand which initializes the liveplayer model and view using separate commands.  Here's the command that initializes the view.  This is where the problem occurs.

:
package com.multicastmedia.apps.live.liveplayer.controller
{
import com.multicastmedia.apps.live.liveplayer.view.components.ControlsView;
import com.multicastmedia.apps.live.liveplayer.view.components.CountdownView;
import LivePlayer;
import com.multicastmedia.apps.live.LivePlayerModule;

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

import com.multicastmedia.apps.live.liveplayer.view.mediator.ControlsMediator;
import com.multicastmedia.apps.live.liveplayer.view.mediator.ApplicationMediator;
import com.multicastmedia.apps.live.liveplayer.view.mediator.VideoDisplayMediator;
import com.multicastmedia.apps.live.liveplayer.view.mediator.CountdownMediator;

import org.osflash.thunderbolt.Logger;

public class ViewPrepCommand extends SimpleCommand implements ICommand
{

        override public function execute( note:INotification ):void
        {
var lp:LivePlayer = note.getBody() as LivePlayer;

Logger.debug("ViewPrepCommand::execute");

            facade.registerMediator( new ApplicationMediator( note.getBody() ) );
            // BLOWUP: TypeError: Error #1009: Cannot access a property or method of a null object reference. at com.multicastmedia.apps.live.liveplayer.controller::ViewPrepCommand/execute()[C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\mediaplayer_live_working\mediaplayer_live\src\com\multicastmedia\apps\live\liveplayer\controller\ViewPrepCommand.as:35]
facade.registerMediator( new VideoDisplayMediator( lp.videoDisplayView ));
facade.registerMediator( new ControlsMediator( lp.controlsView ) );
facade.registerMediator( new CountdownMediator( lp.countdownView ));
        }
}
}

I'm sure my mistake is obvious to the experienced eye, but I am stuck nonetheless.  Any idea what could be happening?


Thanks in advance.
27  PureMVC Manifold / MultiCore Version / Flash only Demo? on: June 04, 2008, 08:04:19
May I suggest an all-AS3 example, sans Flex?  I'm having trouble with things like the PipeAwareModule utility extending MovieClip instead of ModuleBase, resulting in the need for an init method to account for MovieClip not accepting constructor arguments.
28  PureMVC Manifold / Demos and Utils / Re: Pipes - A PureMVC AS3 MultiCore Utility on: June 01, 2008, 07:14:29
I get the idea of a shell being on the same level as any other core, etc, and managing messages between cores, but specifically in the case of PipeAwareModule (org.puremvc.as3.multicore.demos.flex.pipeworks.common) -- I assume there's nothing tying this to the use of mx.modules.* -- that is, I can have my PipeAwareModule extend MovieClip instead of Module, right?

I suppose my overall question is can I do the same thing in without Flex or the Flex framework?  This will be an important distinction for those of us using Flash only.  In my case, I need to be sure this is the reality before I move forward with a really large codebase using Pipes.
29  PureMVC Manifold / Demos and Utils / Re: Pipes - A PureMVC AS3 MultiCore Utility on: June 01, 2008, 12:14:49
I see in the demo that mx.modules.ModuleBase is used in the PipeAwareModule.  I assume extending MovieClip would be OK for Flash AS3 modular apps?
30  PureMVC Manifold / Demos and Utils / Re: Pipes - A PureMVC AS3 MultiCore Utility on: May 27, 2008, 06:59:03
I'm working in AS3, using a extended MovieClips to kick off each facade (core).  My Shell is also a MovieClip.  Would I implement Pipes in my applications' facades, or in the main class?  Also, would my Shell take on a different role than my cores (would it manage all the Pipes stuff)?
Pages: 1 [2] 3