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 / MultiCore Version / Re: Flash CSS/AS3 example of loading external swf as module under MultiCore - Help on: August 18, 2008, 09:38:38
Just about have the problem licked!

Turns out, that the problem was due to the Document class of the main shell/app and the document class of the loading module having the same name. (ie both were called Main.as). When the module/external swf tried to load in, the Main.as class of the shell was overriding or superseding that of the Main.as of the module, and hence the weird identity crisis. In effect the Main.as of the shell was reinitializing and rerunning its start up routine.

To solve the problem, I went in and named my document class for my module/external swf to Module.as, or something different than whatever you named the document class for your main app/shell.  The module is now loading in and displaying and running its own PureMVC startup routine.

Thanks for the ideas and help.

I'm going to try and clean up the example and try and add pipes next. If all goes well I will post the example up for others to have a look at with all the code.

Cheers,

Richard
2  PureMVC Manifold / MultiCore Version / Re: Flash CSS/AS3 example of loading external swf as module under MultiCore - Help on: August 16, 2008, 04:15:04
Just to give a little more detail...

Here is my document class for my shell:

:
package
{
import com.ethicalentertainment.monkeyshell.ApplicationFacade;
import flash.display.Sprite;
import com.carlcalderon.arthropod.Debug;

public class Main extends Sprite
{
private var facade:ApplicationFacade;
public static const NAME:String = 'Shell'; //Main Application/Core ID/NAME

public function Main()
{
Debug.log("Step 1 - SHELL Creating Instarce of Facade");
facade = ApplicationFacade.getInstance(NAME); //mulicore way

Debug.log("Step 2 - SHELL calling Facades startup");
facade.startup( this.stage );
}
}
}

And Here is the document class for my external "swf/cs3 module":


:
package
{
import com.ethicalentertainment.monkeymodule.ApplicationFacade;

import flash.display.Sprite;

import com.carlcalderon.arthropod.Debug;

public class Main extends Sprite
{
private var facade:ApplicationFacade;

//Main Application/Core ID/NAME
public static const NAME:String = 'Module';

public function Main()
{
Debug.log("Step 1 - MODULE creating new Instarce of Facade");
facade = ApplicationFacade.getInstance(NAME); //mulicore way

Debug.log("Step 2 - MODULE calling Facades startup");
facade.startup( this.stage );

}
}
}

Here is my Shell ApplicationFacade:

:
package com.ethicalentertainment.monkeyshell
{
    import org.puremvc.as3.multicore.interfaces.IFacade;
    import org.puremvc.as3.multicore.patterns.facade.Facade;
    import com.ethicalentertainment.monkeyshell.controller.StartupCommand;
import com.carlcalderon.arthropod.Debug;
   
    public class ApplicationFacade extends Facade implements IFacade
    {
        // Notification name constants
        public static const STARTUP:String  = "startup";
        public static const INITIALIZE_ENGINE:String  = "initializeEngine";
        public static const SECTION_CHANGED:String  = "sectionChanged";
public static const VIEW_SCREEN_START:String  = "viewScreenStart";

//////////////////////////////////////////////////////////////
//Constructor of ApplicationFacade
public function ApplicationFacade( key:String )
{
super(key);
}
//////////////////////////////////////////////////////////////
public static function getInstance( key:String ) : ApplicationFacade
        {
Debug.log("getInstance being called on Facade");
            if ( instanceMap[ key ] == null ) instanceMap[ key ] = new ApplicationFacade( key );
            return instanceMap[ key ] as ApplicationFacade;
        }
/////////////////////////////////////////////////////////////
        override protected function initializeController() : void
        {
            super.initializeController();
            registerCommand( STARTUP, StartupCommand ); //can choose to map a notification to a command if you want, but not requried
        }
        //////////////////////////////////////////////////////////////
        public function startup( stage:Object ):void
        {
        Debug.log("Step 3 - AppicationFacade sending notification to startup, which triggers startup command");
        sendNotification( STARTUP, stage );
        }
        //////////////////////////////////////////////////////////////
    }
}

And here is the Facade for my external swf/module:

:
package com.ethicalentertainment.monkeymodule
{
    import org.puremvc.as3.multicore.interfaces.IFacade;
    import org.puremvc.as3.multicore.patterns.facade.Facade;
    import com.ethicalentertainment.monkeymodule.controller.StartupCommand;

import com.carlcalderon.arthropod.Debug;
   
    public class ApplicationFacade extends Facade implements IFacade
    {
        // Notification name constants
        public static const STARTUP:String  = "startup";
        public static const INITIALIZE_ENGINE:String  = "initializeEngine";
        public static const SECTION_CHANGED:String  = "sectionChanged";

public static const VIEW_SCREEN_START:String  = "viewScreenStart";


//////////////////////////////////////////////////////////////
//Constructor of ApplicationFacade
public function ApplicationFacade( key:String )
{
super(key);
}
//////////////////////////////////////////////////////////////
public static function getInstance( key:String ) : ApplicationFacade
        {
Debug.log("getInstance being called on Facade");
            if ( instanceMap[ key ] == null ) instanceMap[ key ] = new ApplicationFacade( key );
            return instanceMap[ key ] as ApplicationFacade;
        }
/////////////////////////////////////////////////////////////
        override protected function initializeController() : void
        {
            super.initializeController();
            registerCommand( STARTUP, StartupCommand ); //can choose to map a notification to a command if you want, but not requried
        }
        //////////////////////////////////////////////////////////////
        public function startup( stage:Object ):void
        {
        Debug.log("Step 3 - AppicationFacade sending notification to startup, which triggers startup command");
        sendNotification( STARTUP, stage ); //send out a startup notification that will initiated teh StartupCommand
        }
        //////////////////////////////////////////////////////////////
    }
}

I believe the error message I was getting was something like "can't reference null object" when the shell tries to load in the module.

I have all the other code for for my facades and mediator and proxies in the zip file for both the shell and the zip.

Could it be a problem with both the Shell and the external SWF trying to reference the stage? Or maybe a timing issue (ie something hasn't initialized in time?)

Since we are dealing with multicore, I did move things that used to be in the contructor to the onRegister, so I  don't think that the problem.

Is there something different that needs to happen with my external SWF/module to make it load in properly under Flash CS3/PureMVC multicore?

Really appreciate some thoughts or ideas in if what I'm trying to do is possible in Flash CS3/PureMVC multicore and if so, what I seem to be missing.

Cheers,

Richard



3  PureMVC Manifold / MultiCore Version / Flash CSS/AS3 example of loading external swf as module under MultiCore - Help on: August 15, 2008, 11:19:09
Hi Cliff and other fellow PureMVC developers.

I have been using the Standard version of PureMVC under Flash CS3, and I've been very happy with the results.

I am really excited to make the jump to Multicore for Flash CS3, but since there are no examples, I thought I'd have a go at doing one up. In particular, I wanted to know how to take external standalone swf files (they may use the PureMVC Multicore framework or not) and be able to load one of these into a "Shell" app. My understanding was that Multicore allows for multiple instance of the PureMVC Framework to run under one shell in 1 VM, and that there is no need to bump these externally loaded apps into a separate ApplicationDomains, since multiple instances of the framework are permitted under MultiCore, which was not the case with the old Standard edition as far as I understand.

I did up a very simple SHELL that initializes with it's own key, and then I did up a simple module(external SWF if you CS3 guy/gall), which also initializes with a different key. The main app fires up, and has a button you can click that tries to load the module(external PureMVC enabled swf).

What I was expecting was for the App/Shell to load in the external swf(module) and display it, and because it has it's own key, it carries on with its startup routine, independent of the main app/shell.

What I am finding is that the app/shell tries to load in the module/swf file, but then for some reason, instead of the module running it's own starup routine, it causes the main app/shell to rerun it's startup routine. As far as I am aware, this should not happen, since both shell and module were created with different keys. It's like the module is having an identity crisis or something.

Also, When I try loading in a module/external swf with no PureMVC code in it, it loads into the shell no problem and displays as expected.

I have uploaded both the shell and the module code for people to have a look at. If anyone has as any ideas what is going on, or what I'm missing, I'd really appreciate the help. Once I have this working, I'd like to get it working with pipes, spiffy it up and submit if for an example since there are none currently for Flash CS3.

Files:
http://www.ethicalentertainment.net/AS3_Multicore_Modules_Example.zip

Also, if your curious I'm using Anthropod to view my trace/debugs. I've found it really useful for Flash and Air projects.
http://arthropod.stopp.se/

Cheers,

Richard




Pages: [1]