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

Pages: [1] 2
Print
Author Topic: Is there a pure AS3 demo for Multicore  (Read 24317 times)
unicorn
Courseware Beta
Newbie
***
Posts: 7


View Profile Email
« on: March 15, 2008, 11:40:35 »

Hi all,

Has anyone done a small demo of the multicore for AS3.

Thanks
Logged
trilec
Sr. Member
****
Posts: 52



View Profile WWW Email
« Reply #1 on: March 16, 2008, 04:35:36 »

Hi rocknroll,
Currently in the demo section there is no pure AS3 demo however, a good starting point would be to review the modularity demo. This contains 85% or so AS3 code and gives you a great overview from a pureMVC Outlook.
Where the .FLA would normally be involved (i.e. in creating some of the components)
resides in the components folder under the view folder.
Exampe :Modularity\src\org\puremvc\as3\multicore\demos\flex\modularity\view\components
WidgetCanvas.mxml
:
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"
width="80%" height="80%" cornerRadius="12"
borderStyle="solid" backgroundAlpha="1"
backgroundColor="#FFFFFF"
horizontalAlign="center"
verticalAlign="middle"
dropShadowEnabled="true" >

</mx:VBox>
   
I am in a similar circumstance as I don't use Flex but find I can still get a good understanding of the structure by reviewing the code, anyway I hope that helps.
You also might be unable to get a more information by reviewing some of the flex commands like Vbox.

Cheers
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #2 on: March 16, 2008, 07:59:48 »

It is definitely on the todo list!

-=Cliff>
Logged
unicorn
Courseware Beta
Newbie
***
Posts: 7


View Profile Email
« Reply #3 on: March 21, 2008, 02:11:29 »

I managed to get the the multicore example working in flash.  Does anyone have a good idea how to dynamically load in a module in flash. 

If flex, the module loader takes care of loading in the sub application.  However in flash, this is not the case,

Thanks
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #4 on: March 21, 2008, 06:52:01 »

SWFLoader

-=Cliff>
Logged
unicorn
Courseware Beta
Newbie
***
Posts: 7


View Profile Email
« Reply #5 on: March 22, 2008, 10:30:14 »

Thanks Cliff and community,

My email wasn't very clear but my intended question was:  What is the recommended approach of organizing the structure of dynamically loading of subapps  in a flash development workflow. 

After experimentation, I found a very streamlined flexbuilder workflow to organize to test the subapps and main app.  All sitting under one actionscript project.  Basically, in this structure, each subApp's main .as file is sitting under the root.  To compile SuperWidget, in flexbuilder, right mouse click on SuperWidget.as > set as default application.  Then compile.  Once compiled, SuperWidget.swf will be generated to the output directory (mine is bin).  Then right click on  MulticoreAs3.as > set as default application, then compile.  I have the output directory for this also at bin.  The app should fire off and dynamically load in SuperWidget.

Below is the directory structure:

MulticoreDemoAs3
  - com
      - modular
      - widgetmakers
      - widgetworks
      - libs
      - org
  MulticoreAs3.as
  SuperWidget.as
  CoolWidget.as

-----  Below is code that shows how to dynamically load in SuperWidget  ------


          public function WidgetShell(inStage:Stage){

             coolWidget = new CoolWidget();
             addChild(coolWidget);

            var request:URLRequest = new URLRequest("SuperWidget.swf"); 
            loader = new Loader(); 
            
             loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress); 
             loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete); 
   
               //this.stage.addEventListener(Event.RESIZE, onResize);   
               loader.load(request);
               initializeShell();
         }
         
          private function loadProgress(event:ProgressEvent):void { 
             var percentLoaded:Number = event.bytesLoaded/event.bytesTotal; 
             percentLoaded = Math.round(percentLoaded * 100); 
             trace("Loading: "+percentLoaded+"%"); 
          } 
          private function loadComplete(event:Event):void { 
             trace("loaderContent" + loader.content);
             //var loadedClass:Class = Class(loader.content).
             var hasClass:Boolean = loader.contentLoaderInfo.applicationDomain.hasDefinition("SuperWidget");
             var SuperWidget:Class = event.target.applicationDomain.getDefinition("SuperWidget") as Class;
                       
             
             trace("hasClass " + hasClass);
             var superWidget:IWidget = new SuperWidget();
             trace("widgetworks" + superWidget.getWidgetKey());
             addChild(superWidget as DisplayObject);
             superWidget.setWidgetShell( this );

          } 
 
         protected function initializeShell():void
         {
            coolWidget.setWidgetShell( this );
 
         }

------------------------------------

Btw Cliff, If you like I can send you a working version of the AS3 demo and u can put it into svn.

Thanks Cliff and everyone for a great job



Logged
trilec
Sr. Member
****
Posts: 52



View Profile WWW Email
« Reply #6 on: March 27, 2008, 10:48:00 »

Thanks rocknroll,
This is a structure im working towards for a All As3 MultiCore



T
Logged
unicorn
Courseware Beta
Newbie
***
Posts: 7


View Profile Email
« Reply #7 on: March 31, 2008, 10:22:04 »

Hi Cliff and community,

Here is a use case that we are encountering:

We are dynamically loading/removing sub-widgets in/out of the main "Modularity" shell and would like to be able to get a list of widgets are are currently loaded.  The purpose of this is to be able to facilitate communication between sub-apps and the main app. 

In the framework, instanceMap is the main keeper of all app/sub-apps however, this info is not exposed.  Would it be possible to add the following to the framework.

public function getInstanceMapList():Array

Thank you
Logged
unicorn
Courseware Beta
Newbie
***
Posts: 7


View Profile Email
« Reply #8 on: March 31, 2008, 11:14:37 »

Hi all,

It looks like as3 has a problem with using strings as keys for Arrays.

We were trying to get information from InstanceMap but for some reason we couldn't get anything out of it.  ex: InstanceMap.length doesn't work.  This is solved with the following code:

         var i:int =0;
         for (var key in instanceMap){
         trace(key +" "+i+" "+ instanceMap[key])
         i++
         }
         trace(i)

So it turns out that instanceMap is exposed but the problem is with AS3.

Thanks.
« Last Edit: March 31, 2008, 11:27:22 by rocknroll » Logged
trilec
Sr. Member
****
Posts: 52



View Profile WWW Email
« Reply #9 on: March 31, 2008, 11:44:47 »

Hi rocknroll,
Did you manage to finish up working on the AS3 demo, would it be possible to post a link?
would be great to see what you did with it.

thanks
T
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #10 on: March 31, 2008, 01:37:59 »

In the framework, instanceMap is the main keeper of all app/sub-apps however, this info is not exposed.  Would it be possible to add the following to the framework.

public function getInstanceMapList():Array

No, we do not want widgets having willy-nilly access to everything. If you write an application that supports third-party widget development you need to be *extremely* careful what you give those widgets access to because for some unfathomable reason, people are often want to do malicious things with your data if you give them a chance.

What is needed is simply for the WidgetShell to provide a method for accessing certain information about the other widgets that are loaded. That WidgetShell should have a facility for controlling what widgets can see what. You would need to implement functionality for granting certain permissions to certain Widgets. If you control all the Widgets being loaded and no third parties can create them, then you have your WidgetShell treat all Widgets as privileged.

And also, you are correct. When an array is used as an associative array (strings for keys rather than numeric ordinals) then length will always be zero. Thats an ActionScript issue.

-=Cliff>

Logged
unicorn
Courseware Beta
Newbie
***
Posts: 7


View Profile Email
« Reply #11 on: April 01, 2008, 05:11:36 »

Thanks Cliff,

I absolutely agree with your suggestions for keeping 3rd party widgets in check.  I also agree with the widgetShell being the gate-keeper to the entire framework.  The thing that is different in our implementation is that we are using the widgetShellMediator as the gate keeper.  The main reason for using the widgetShellMediator instead of the widgetShell is that our project needs to dynamically change the communication between the subApps and the main App.  For this use case, we felt that it's more appropriate to use the mediator rather than the widgetShell.  Our situation is unique and we are adapting the framework to fit our needs as we go along, however, we are by no means expert in puremvc so Cliff, any advice from you and the community at large would greatly be appreciated.

Thanks




 
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #12 on: April 02, 2008, 08:35:19 »

Putting logic into the Mediator is not a good practice as it stretches its responsibilities outside its intended role.

Also, the 'touch points' between the PureMVC Cores that are running should always be boundary objects (i.e. view components), which should not know anything about either their Core or the Core to which they are speaking. Now, it may be that the WidgetShell doesn't have any visual representation, but it should be able to send events to its Mediator, so its easy to make it an invisible Sprite, which is lightweight and doesn't really affect the View.

A boundary object in one app/module should talk to a boundary object in the other app. The methods on those boundary objects might do nothing but dispatch events heard by their Mediators, which pass them on via Notification to a Command or other Mediator, or set a property on a Proxy, etc, according to ordinary best practices.

-=Cliff>
Logged
trilec
Sr. Member
****
Posts: 52



View Profile WWW Email
« Reply #13 on: April 02, 2008, 05:55:42 »

Hi Cliff,Steve
Did you look into the HMVC pattern (layered pattern for developing strong client tiers) (close to PAC Pattern)

http://www.javaworld.com/javaworld/jw-07-2000/jw-0721-hmvc.html?page=3

Interesting approch for a structured client-tier architecture and handling the universal question off where do I put Menu, Status, Nav, and Content class assignments within a MVC pattern.
But as I see it, Multicore can handle this situation as long as the definition of the "touch points" is well-defined and perhaps helper functions added to address this communication in a predefined manner.?

We definitely need a few more multicore examples, I feel this is a real hidden strength of pureMVC and also seems similar to HMVC approch :-)
Logged
unicorn
Courseware Beta
Newbie
***
Posts: 7


View Profile Email
« Reply #14 on: April 05, 2008, 12:28:21 »

Trilec,

The link is excellent ! 

We came up with a similar approach based on our team's collective knowledge.  Multicore MVC is not really charting new territory -- all of the design patterns have been done before.  It is really up to us to re-appropriate for our needs.  Trilec, I also agree with you that Multicore MVC in it's first incarnation is the beginnings of HMVC.
Logged
Pages: [1] 2
Print