UPDATE [08/25/08]: Source has been updated using PureMVC 1.0.5 MultiCore.
These days I’ve been playing around with the latest cool utility for PureMVC MultiCore AS3 called “Pipes Utility” developed by Cliff Hall. It’s a very helpful and powerful utility to communicate among all core actors of a module based application using PureMVC.
For a better understanding I created a basic example using modules. It’s just a simple app called “HelloPipes”, which loads and unloads a module for communicating with its shell using Pipes. Module and shell are acting as a core based on PureMVC MultiCore AS3.
The following example including full source may help anybody who is interested in the new Pipe Utility too
.
Example
Full source
HelloPipesSource.zip (Downloads: 3023)
Tips using Modules, PureMVC MultiCore AS3 and Pipe Utility
- Don’t import any classes of a PureMVC MultiCore module within the shell (main application) to avoid any issues at runtime loading and unloading a module. To define constants for using Pipes such as output and input pipe names, which are shared between shell and module, don’t use a reference to any actor. Use a simple “common” class instead, which stores only these constants for sharing by shell and module. Check the
PipeAwareModuleConstants.aswithin the example above. - For communicating from shell to module and return without Pipes use well defined interfaces for the same reason mentioned before.
- Clean up your module to avoid any issues loading and unloading it again. This may be helpfull for a successful garbage collection as well. Check out the code for the module within the example above, which uses an Interface called
IPipeAwareModule. Using this interface the shell forces the cleaning up process of the module before the module will be unloaded. - Disconnect and unregister (if necessary) Pipes connecting shell and modules, when a module is unloaded.
- Remove all PureMVC core actors of a module using
facade.removeCorebefore a module is unloaded to avoid issues reloading it. - General issue: To reduce the file size of a module use the compiler option called
load-externs. For detailed information check the Flex 3 Help: “Compiling modules – Reducing module size“
Helpful links
- “Understanding PureMVC Pipes” by Joshua Ostrom. Great tutorial!
- PureMVC Forum entry: “Pipes – A PureMVC AS3 MultiCore Utility“
- Pipe Utility example named “PipeWorks” by Cliff Hall
Have fun!


July 11th, 2008 at 4:52 am
Good!
July 11th, 2008 at 5:39 am
Hi, when i click on the load Module all i get is the spinning clock, the module is never loaded. Also i notice that there isn’t any SimpleModule.swf anywhere is that the issue ?
July 11th, 2008 at 5:51 am
Sep,
within source (“HelloPipes.zip”) you won’t find any SWFs or Modules. So you have to compile the Module before running the app. To compile the Module called “SimpleModule.swf” using Flex Builder just right click on SimpleModule.mxml -> Run as -> Flex Application.
-Jens
July 11th, 2008 at 7:15 am
I got it working thanks! Could you tell me what are the differences between the pipe method and the Modularity methods, and why did you pick this one ?
July 11th, 2008 at 8:32 am
Sep,
in short words: With Modularity you may define an own API for communicating between shell and modules using events or methods based on well defined Interfaces.
The Pipes Utility has already implemented an API for communicating from shell to one or more modules (and / or back) in a loosely coupled way. Furthermore pipes can do a lot of other things, e.g. filtering or sending queues of messages and more.
Personally I find that the utility is a hard stuff to understand, but at the end it will give you a lot of possibilities for using PureMVC MultiCore AS3 in a well defined way.
-Jens
July 14th, 2008 at 2:36 am
Thanks sectore, I am starting an application with the PureMVC MultiCore AS3 and Pipe Utility, i like the decoupling concept, but i have a question in regards to the development of such an application. Every module has its own pureMCV MultiCore so i was thinking that i could preview them independently, like in Flash i create my “swfModule” from different fla and preview them for testing, but i think you need to load modules in an application to preview them ? Ideally I would like to separate everything in different application so everything is independent and then use the pipes for connections… is that possible ? or should every thing be in just one application ?
July 14th, 2008 at 10:52 am
Sep,
there are different ways to organize your project for creating modular applications and it depends on your needs.
If you would like to run all modules as a “standalone” version without the shell they have to include all sources of all needed classes (incl. Flex framework classes). That means that a module has classes that overlap with the shell’s classes, which increases the module size as well.
Another way is to exclude all classes for a module which are used by module and shell as described here: “Reducing module size”. Using this way a module size are decreased, but it won’t run outside the shell. BTW: The example above based on it.
I highly recommend chapters “Using modules in a single project” and “Using multiple projects” at “Creating Modular Applications” (Note: It based on Flex 2 not 3
)
-Jens
July 14th, 2008 at 12:13 pm
Thanks for that, its very helpful. I am glad you told me about the pureMVC at FOTB07. I am from Australia and we were at the same table in the Casino
July 15th, 2008 at 6:54 am
@Sep: Hey Brett, I remember our talk at FOTB07. It’s nice to meet you here again
BTW: Few weeks ago I noticed your new blog – keep on blogging
-Jens
July 22nd, 2008 at 12:14 am
[...] A basic PureMVC MultiCore AS3 example using Pipes Utility and Modules [...]
July 22nd, 2008 at 11:34 am
Thank you very much ,sectore^_^
Your demo is simple and wonderful!
But when I goto the link [“Understanding PureMVC Pipes” by Joshua Ostrom. Great tutorial!], which have a demo like you, but it make me confused@_@, I can’t found its lib from the source of it, so do you have that?
I just found other demo of that at http://dluminosity.com/demos/modules/MortgageApp.html, but this doesn’t use pipes, and the lib is not the same as the first.
So, please give me some suggestion about that
Thanks for your time!
mani.
July 22nd, 2008 at 11:49 am
mani, thanks for your feedback! I’m glad to see that the “HelloPipes” sample helps you.
P.S.: Please get in contact with Joshua for getting the full source of his example – I’m sure that he will help you
-Jens
July 24th, 2008 at 1:19 am
When I try to import with Flex Builder 3 I get:
“Not a valid archived project. If the zip was not created via Export Flex Project, use Import > General > Existing Projects into Workspace.”
Doesn’t look like the archive has all of the project files in it. I can still import it into an existing Flex project but would be good to have the exact project.
July 31st, 2008 at 9:16 pm
Hi sectore!
I’m very happy to find this tutorial. I’m currently building a Flex/PureMVC_multiCore and it’s like scramble eggs in my head.
I’m building a very complex program (at least for me I guess…) and I’m not happy with the structure I come up with.
I like very much yours. So much I started to refactor my project based on your code.
I have a question: When I load modules, I need to send messages to the shell as quickly as possible (my modules act like plugins to the shell to, adding some functionnalities). I tried to put
sendNotification( ApplicationFacade.SEND_MESSAGE_TO_SHELL, “Module onRegister” );
inside the onRegister() of my module’s mediator but nothing happens.
Where is the best place I should place theses initialization messages so they get fired as soon as possible?
thanks for your work!
August 4th, 2008 at 9:50 am
Alian,
to send messages from module to shell all needed pipes have to be registered and connected. The
ShellJunctionMediatorstarts this process after receiving aFlexEvent.INITIALIZEfrom the module calling its method namedconnectModule(). During this process theSimpleModulewill be informed to accept an output- and input-pipe calling its methodsacceptInputPipe()andacceptOutputPipe()from shell to register pipes or to add pipeListener as well.Anyway, to simplify to handle the result of all these things just wait until the Module has fired it’s
FlexEvent.CREATION_COMPLETE. After that a module may send a first message to its shell as soon as possible-Jens
August 4th, 2008 at 11:30 am
[...] examples, feedback and guidance which is a must read for getting a grasp on MultiCore so check Jens Krause and Joshua Ostrom. Jens props for your tip on the definition of a clean up method in the [...]
August 5th, 2008 at 1:26 am
Hey Sectore,
Its a bit off topic but I remember our conversation at the FOTB07 about flex builder and you told me you were using some shortcuts to generate the getter/setter and all other kinds of cool stuff to improve the coding speed. Could you share this, and how you set it up in a post or just point me in the right direction ? I have been trying today to do it but I feel a bit confused.
August 20th, 2008 at 1:55 pm
[...] HelloPipes tutorial using MultiCore and Flex Modules. [...]
August 22nd, 2008 at 6:46 am
Really cool…
I have implemented one for myself, I will give it a try, surely I will get more clear picture of Shell/Module concept now
Thanks
November 11th, 2008 at 8:43 am
hi,
Can i load swf and use the function? like DLL.Thank
January 30th, 2009 at 10:10 am
Just came back here to mention that six months back when i was taking my first steps in learning PureMVC + Pipes, i found this example invaluable!
A friend and colleague was looking out for similar content and this it it.
March 3rd, 2009 at 1:04 pm
Hi, very cool tutorial!!
How can i achieve the communication between modules?Can you explain the right way to do it?
Thanks in advance
Regards
Lorenzo
July 30th, 2009 at 6:04 pm
Great Thanks.
Could someone suggest how to split this smaple to different project for the Shell , Modules and common class for constants [RSL].
I tried but really got frustrated while loading the module to the shell. In the Module mediator im getting null expection error message on this call “acceptOutputPipe”.
Thanks,
Anandh
November 2nd, 2009 at 1:05 pm
Hey Jens – just wanted to say that this demo contains it all for getting started with Pipes – brilliant and thanks very much – I really couldn’t have got there without this.
My one question is this – why do you maintain a reference to the Module’s ApplicationFacade in the mxml file when surely the place to fire off notifications is in the SimpleModuleMediator – isn’t the mxml file simply a view which kicks off pureMVC in the initializeHandler? Wouldn’t it be better to fire off Flash events which are listened to by the SimpleModuleMediator and do the pureMVC notifications from there?
November 9th, 2009 at 9:44 am
[...] i learned from: pureMVC Multicore pipes: Jens Krause’s Blog 10 tips for working with pureMvc WS-Blog » A basic PureMVC MultiCore AS3 example using Pipes Utility and Modules. Frédéric Saunier’s Blog Flash only «Modules with PureMVC pipes» [...]
January 16th, 2010 at 12:55 am
[...] Simple tutorial of Pipes integration with code source avaiable [...]