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  PureMVC Manifold / Demos and Utils / Re: StateMachine - A PureMVC AS3 Utility on: April 11, 2009, 12:13:49
Hi Guys,
I was trying to connect the state machine with some unit testing (Fluint and FUnit) and came to the following problem: whenever i want to see if a given state was 'changed' I allways see the previous state. Here is my code:
:
<state name={STATE_REGISTERING} changed={REGISTER_TRY}>
    <transition action={ACTION_REGISTER_OK} target={STATE_REGISTERED}/>
</state>

So I make a listener for REGISTER_TRY and in that function I want to check the state if it's STATE_REGISTERED. But it's not, and the reason is that in StateMachine class:

:
// Send the notification configured to be sent when this specific state becomes current
if ( nextState.changed ) sendNotification( currentState.changed, data );

// Notify the app generally that the state changed and what the new state is
sendNotification( CHANGED, currentState, currentState.name );

In my code the CHANGED notification upadtes the status variable(I listen for this in a Mediator)
So you see, the notification with my data is coming sooner, and the notification of the state changed is coming later, so my status variable is changing later, so I allways see the previous state first.
So what I did, I replaced the 2 lines with each other, and now my state changes first, then comes my notification where I can check the state...

:
// Notify the app generally that the state changed and what the new state is
sendNotification( CHANGED, currentState, currentState.name );

// Send the notification configured to be sent when this specific state becomes current
if ( nextState.changed ) sendNotification( currentState.changed, data );

Is it an error or am I doing something the wrong way?
2  PureMVC Manifold / MultiCore Version / loading external applications problem on: December 16, 2008, 03:06:16
Hi Guys,

I'm banging my head for 2 days now with this and finally gave up.
I have an application (just a bunch of normal mxml with puremvc) and I'm loading another application into it (mxml with puremvc like the first one). All the flex, puremvc multicore, pipes libraries are externals (not compiled into the code)

Whenever I load the 2nd into the first I want to raise an event in order to connect the 2 through pipes.
And that's where the problem comes in, when this function is called finally then the module is null!

public function connectModule( module:IPipeAwareModule):void
{
junction.registerPipe( ConstPipe.PIPE_SHELL_TO_MODULE,Junction.OUTPUT,new TeeSplit() );
junction.registerPipe( ConstPipe.PIPE_MODULE_TO_SHELL,Junction.INPUT,new TeeMerge() );
junction.addPipeListener( ConstPipe.PIPE_MODULE_TO_SHELL,this,handlePipeMessage );
var moduleToShell: Pipe = new Pipe();
module.acceptOutputPipe( ConstPipe.PIPE_MODULE_TO_SHELL, moduleToShell );
var shellInFitting: TeeMerge = junction.retrievePipe( ConstPipe.PIPE_MODULE_TO_SHELL ) as TeeMerge;
shellInFitting.connectInput( moduleToShell );
var shellToModule: Pipe = new Pipe();
module.acceptInputPipe( ConstPipe.PIPE_SHELL_TO_MODULE, shellToModule );
...
}


Here are some versions I tried with:

SWFLoader


protected var loader:SWFLoader;

public function loadApp():void 
{
loader = new SWFLoader();
var apploc:String = "XXXAPP.swf";

loader.addEventListener(Event.COMPLETE, completeHandler);
loader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);

var context:LoaderContext = new LoaderContext();
context.applicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);
loader.loaderContext = context;
loader.trustContent = true;
loader.source = apploc;
loader.load();         
MXMLholder.addChild(loader);
}

private function completeHandler(event:Event):void
{   
var ev:MyEvent = new MyEvent(ELOADED);
ev.data = loader.loaderInfo.applicationDomain.getDefinition("XXXAPP") as Class;
ev.data = loader.content as IPipeAwareModule;
ev.data = (loader.content as SystemManager).application;
ev.data = loader.content as SystemManager).application as IPipeAwareModule
//And i can continue with all the variations of the above ...
// None of those are working when I dispatch the event the module is always null in connectModule
dispatchEvent(ev);
}


I've also tried with the Loader and ModuleLoader classes ... without sucess.
The application is loaded, appears in the GUI and works correctly inside the shell application.
The problem is that when the event is dispatched (in the completeHandler) and finally the connectModule function is called the module parameter (module = ev.data) is allways null.
I tried to listen after the complete event for the FlexEvent.INITIALIZE event, but that was not dispatched... I suspect I should listen to some initialize event ...
On the other hand if from the module application I call manually the connectModule (in the shell application) it allways works :)
But that's just disgusting from a programming practice perspective isn't it?
Pages: [1]