Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Welcome, Guest. Please login or register.
April 27, 2017, 05:29:58 PM
Home Help Search Login Register
News: ATTENTION: Spambots must die! Humans must visit http://contact.futurescale.com to request forum access.
Pages: [1]
Print
Author Topic: loading external swf as viewcomponent  (Read 2590 times)
4ucai
Jr. Member
**
Posts: 17


View Profile
« on: November 02, 2011, 08:16:37 AM »

Hi, im still learning how to get around the PureMVC framework.
Im a bit confused as to how i should load external swf(basically they are movieclips which contains buttons, sprites, etc.). I separated my single project(all movieclips,etc. in 1 big .fla file) into modules(e.g. editTools,commonTools).
I did these things so far..
1. In my applicationfacade
Code:
override protected function initializeController():void {
            super.initializeController();
    //starting the application
            registerCommand(STARTUP, StartupCommand);
}
2.In on StartupCommand.as
Code:
public class StartupCommand extends SimpleCommand implements ICommand {
        // Register the Proxies and Mediators
        override public function execute(note:INotification):void    {
// Create and register proxy
facade.registerProxy(new CanvasProxy());
                        //the stage here should add all the viewcomponent
var stage:Stage = note.getBody() as Stage;
                        //how can i get reference to the external swf
                        //and add it on stage and pass reference to the mediator
                        //stage.addChild(theswf);
                        //facade.registerMediator(new EditToolMediator(theswf));
       }
}

Btw, i have a ToolbarProxy which i think should handle the loading of swf
Code:
public class ToolbarProxy extends Proxy implements IProxy {

//Cannonical name of the Proxy
public static const NAME:String = 'ToolbarProxy';

public function ToolbarProxy() {
super(NAME, new ToolbarVO()); //pass the cannonical name to the superclass
}

public function loadToolbar():void
               {
                    var request:URLRequest = new URLRequest();
                    var loader:URLLoader = new URLLoader();
 
                      request.url = vo.dataURL;
 
                     loader.addEventListener( Event.COMPLETE, handleLoadingToolbarComplete );
 
                   loader.load( request );
              }
 
        private function handleLoadingToolbarComplete(e:Event):void
        {
            vo.Toolbar_mc = e.target;
 
            sendNotification( PureMvcConstants.TOOLBAR_LOADED, vo.Toolbar_mc );
        }
 
        public function get vo():ToolbarVO
        {
            return data as ToolbarVO;
        }
And the ToolbarVO
Code:
public class ToolbarVO
{
public function ToolbarVO()
{
public var dataURL:String = 'toolbar.swf';
public var Toolbar_mc:MovieClip = new MovieClip();
}

}


More Power &
Best Regards
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2865



View Profile WWW
« Reply #1 on: November 02, 2011, 09:52:46 AM »

It's not a good idea to mix View tier classes in your Proxies and VOs. Value Objects are usually intended to represent and persist your domain model; the data your app works with. Step back from your application and consider what actual persistable data it works with. Write VOs to represent that data so all tiers of the app can work with it. Write Proxies to persist and retrieve those VOs and make them available to the system.

Use a Mediator to load the module and keep the reference. This stretches the Mediator's normal responsibilities a bit but not as much as having a Proxy be involved in View related business. Mediators are usually passed View Component instances to be mediated, but they may also create the instances themselves or load the instance. They may need to consult a ConfigProxy that gives them the info about where to load the module from (it would've previously loaded a configuration file).

Also if you intend to have PureMVC code in those modules, be sure to use the MultiCore version rather than the Standard version.
Logged
4ucai
Jr. Member
**
Posts: 17


View Profile
« Reply #2 on: November 02, 2011, 10:30:46 AM »

thnx for the replay appreciate it very much..i will take a look at multi core
Logged
Pages: [1]
Print
Jump to: