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  Announcements and General Discussion / General Discussion / Re: Call functions and hold references from other ViewComponents allowed? on: October 16, 2008, 04:51:39
thanks a lot for your answer.   

:
Just out of curiosity, why does your mediator access facade as _facade?
You're right. The var name is facade not _facade.
I forgot to mention, that it was just more pseudo/example Code. So i don't looked to much into it. 
2  Announcements and General Discussion / General Discussion / Call functions and hold references from other ViewComponents allowed? on: October 15, 2008, 06:24:28
Hi,   

for example:

Let's say we have a Image Gallery.
The Image Gallery has a 'ThumbnailOverview' Component. The corresponding Mediator is 'ThumbnailOverviewMediator'. 

There is also a 'ThumbnailItem' Component with the corresponding Mediator called 'ThumbnailItemMediator'.

The ThumbnailOverview and Mediator creates and hold the ThumbnailItems:

:

// ThumbNailOverviewMediator

//....

public function makeThumbnails():void
{
    for(var i:int = 0;i<10000; i++)
    {
        var thumbNail:ThumbnailItem = new ThumbNailItem();
        _facade.registerMediator(new ThumbnailItemMediator(thumbNail));
 
       thumbNailOverview.insertThumbNail(thumbNail);
    }


The 'ThumbnailOverview' then could look something like this:

:

// ThumbnailOverview ViewComponent

//.....

public function insertThumbNail(thumbNail:ThumbNailItem):void
{
   addChild(thumbNail);
   listOfThumbNails.push(thumbnail); // Array which hold all the Thumbnail Items
   thumbNail.addEventListener(ThumbNailItem.REMOVED, thumbNailRemoved);
   thumbNail.testFunction();
}


Would this ok, that the 'ThumbnailOverview' hold references to ThumbNailItems, add itself as an Listener and also called Functions on the ThumbNailItem?   

3  Announcements and General Discussion / Architecture / Why received this Mediator the STARTUP Event? on: April 23, 2008, 02:36:37
Hi,

just a generally question.
Let's say we have this simple Application:

ApplicationFacade Class:
:

//...............

public function startup(app:App):void
{
       sendNotification(STARTUP, app);
}
 
// Register Commands with the Controller
override protected function initializeController():void
{
       super.initializeController(); 
       registerCommand(STARTUP, StartupCommand); 
}

//..................

StartupCommand Class:
:


//.........

override public function execute(notification:INotification):void
{
var app:App = notification.getBody() as App;
var mediatorName:String = AppMediator.NAME;

facade.registerMediator(new AppMediator(mediatorName, app));
}

//.......


AppMediator Class:
:

//.......
override public function handleNotification(note:INotification):void
{
switch(note.getName())
{
case ApplicationFacade.STARTUP:
    trace("AppMediator recivied the STARTUP EVENT");
    break;
}
}

override public function listNotificationInterests():Array
{
return [
    ApplicationFacade.STARTUP
];
}

//.......



App Class
:

//........

public function App()
{
    var facade:ApplicationFacade = ApplicationFacade.getInstance();
    facade.startup(this);
}

//.........


Like you can see, the AppMediator listening for the STARTUP Event.
When you start this Application he also received this Event. Exactly this makes me curios.
Let's take a look at the start order:

1.) "App" initializes the ApplicationFacade and call the startup function.
2.) The ApplicationFacade sends a STARTUP Event.
3.) Because the Controller listens for this Event, he create/start the "StartupCommand".
4.) This Command create the "AppMediator" ...

At Point 2 the STARTUP Event is throwing. At this Point the "AppMediator" doesn't exist.
Only now at Point 4, the Command creates the Mediator. 

So, why the "AppMediator" actually received the STARTUP Event?
4  Announcements and General Discussion / Public Demos, Tools and Applications / Re: pureMVC example application Outlines on: March 19, 2008, 07:53:28
For AS3 there will be an UML Software called "Saffron". It is not released yet, but it looks that's it will released soon.
Here is the Blog with infos about this software.
5  Announcements and General Discussion / Architecture / Re: Multiple Views of the same components on: January 29, 2008, 07:44:52
Take a look at the "HelloFlash" Example.

In this example you can see, how to make the Mediator name dynamically.
6  Announcements and General Discussion / General Discussion / Why not using Event System for the Delegates? on: December 21, 2007, 05:49:07
Hi,

sorry it's maybe Offtopic, but why you are not using Events for the Delegate?
For example in the "ApplicationSkeleton" App.

In the Class "ResourceProxy":
:

...

var delegate : LoadXMLDelegate = new LoadXMLDelegate(this, url);

...

Why not making use of Events here, like for example this:

:

var delegate:LoadXMLDelegate = new LoadXMLDelegate(url);
delegate.addEventListener(LoadXMLDelegate.LOADCOMPLETE, result);

The Cairngorm Framework also not using Events for the Delegates.
Click on the "CMD" and "Business Delegate" Symbol, to see the Code below.

It seems, there must be a reason, don't using Events here. But why not?
7  PureMVC Manifold / Bug Report / [ DEFUSED ] "facade.removeMediator" doesn't work properly? on: September 28, 2007, 10:19:23
Hi cliff,

i just wanted to test what happens, when you remove a Mediator.
So I took the HelloSprite Example, and added some Code.

In the "StageMediator.as" File on Line 93, I added "facade.removeMediator("sprite1");":

:
...
case ApplicationFacade.STAGE_ADD_SPRITE:
var params:Array = note.getBody() as Array;
var helloSprite:HelloSprite = new HelloSprite( spriteDataProxy.nextSpriteID, params );
facade.registerMediator(new HelloSpriteMediator( helloSprite ));
stage.addChild( helloSprite );
facade.removeMediator("sprite1"); // <----------  Remove the Mediator with the Name "sprite1" -----------------------
                    break;
...


And in the "HelloSpriteMediator.as" File on Line 106, I added an trace:

:
...
private function onSpriteDivide(event:Event)
{
helloSprite.color=spriteDataProxy.nextSpriteColor(helloSprite.color);
var params:Array = [ helloSprite.xLoc,
     helloSprite.yLoc,
-(helloSprite.xVec),
-(helloSprite.yVec),
helloSprite.size,
helloSprite.color
];

sendNotification( ApplicationFacade.STAGE_ADD_SPRITE, params );
trace(getMediatorName()); <--------------- Trace his own MediatorName ------------------------------
}
...


What I expects was, that the "sprite1" still moving around, but because his Mediator was removed, it will not add new "HelloSprite" Sprites,
and it will not trace his MediatorName anymore.

But this was not the case. Instead of this, it does the following:

- The Sprite "sprite1" stopped moving
- Now, when you move the Mouse over the "sprite1", it adds new "HelloSprite" Sprites.
- It still trace "sprite1", when you move the Mouse over it.

It seems, that the Mediator is not delete properly. But even maybe the Mediator is still there, why does the Sprite stop to move? The Code for moving is in the "HelloSprite" Class, not in the Mediator Class.

Is this behavior correct, or is there something wrong?   
8  Announcements and General Discussion / General Discussion / Re: How you remove a specific Mediator? on: September 21, 2007, 12:21:41
Thanks, that's a great Idea to solve this.  :)

9  Announcements and General Discussion / General Discussion / How you remove a specific Mediator? on: September 21, 2007, 11:00:43
Hi,   

when you want remove an Mediator, you use the "removeMediator()" method from the facade instance. As paramter he takes the name of the Mediator, for example:
:
facade.removeMediator(HelloSpriteMediator.getMediatorName());
But what is, when you have more Objects of the same Mediator, and you want remove only one specific Mediator?

For example:

:

for(var i=0; i<=10; i++)
{
   var helloSprite:HelloSprite = new HelloSprite(...);
   helloSprite.name = "helloSprite" + i;
   facade.registerMediator(new HelloSpriteMediator( helloSprite ));
   stage.addChild( helloSprite );
}


This Code generate 10 Instances of "HelloSprite" Objects, and his Mediator, and put it in the stage Displaylist.

Now you want remove the "helloSprite5" instance.
To remove the "helloSprite5" DisplayObject, you can make this:

:
var tmpSprite:HelloSprite = stage.getChildByName("helloSprite5");
stage.removeChild(tmpSprite);

But how you remove only his corresponding "HelloSpriteMediator"?
Because, when you do this:

:

facade.removeMediator(HelloSpriteMediator.getMediatorName());


it would also remove the Mediators from the other instances, because all Mediators have the same Name, right?

A Mediator has a static constant Name. So every Mediator has the same name.

How you can now remove only an specific Mediator?
10  Announcements and General Discussion / General Discussion / Re: Doesn't send the Model/Proxy an change Event? on: September 19, 2007, 11:30:54
Thanks for your answer  :)

When working with Flex and AIR, we have data structures (ArrayCollection/XMLListCollection) which already handle this communication for us.


Is that only working in Flex and AIR?
In Flash and AS3 only Projects, you must make such notifications for the views manually with 'sendNotification(...)' and so on?
11  Announcements and General Discussion / General Discussion / Doesn't send the Model/Proxy an change Event? on: September 19, 2007, 09:41:52
Hello,

in a Classic MVC Architecture, the Model dispatch an Event to his listeners, when values in the Model are changed. 
It looks that in PureMVC, the Model or Proxy doesn't send such an Event.


Let's say, some value is changed in a Proxy/Model, and now I want, that other views react on this change.
How does it work in PureMVC?
Pages: [1]