PureMVC Architects Lounge

Announcements and General Discussion => General Discussion => Topic started by: eball on February 15, 2009, 11:56:26



Title: dynamic instantiation
Post by: eball on February 15, 2009, 11:56:26
I am using the superPanel utility with an associated mediator to handle some sizing issues.
When I add an instance of superPanel via mxml, everything work fine:
:
xmlns:sh="shell.view.components.*"...
<sh:SuperPanel id="superPanel" title="SuperPanel 01"
x="0" y="0" width="345" height="180"
layout="absolute" showControls="true" enableResize="true" >
<mx:Label text="asfd" />
</sh:SuperPanel>

When I add instances dynamically:
:
var newPanel:SuperPanel = new SuperPanel;
container.addChild(newPanel)
... the class is instantiated, I can visually see the new instance of SuperPanel, and the SuperPanelMediator loads..... however, although the mediator loads, it doesn't run the "onRegister" method, or "listNotificationInterests" etc.

Without this, the mediator functionality (ie: notifications regarding the sizing functionality) does not work.
Please help.


Title: Re: dynamic instantiation
Post by: puremvc on February 16, 2009, 06:07:46
Is it possible yor are not giving each mediator a unique name? If you instantiate a mediator more than once then you can't use a handy NAME constant for its name, you must generate a unique name. See the HelloFlash demo for a Mediator that does this.

-=Cliff> 


Title: Re: dynamic instantiation
Post by: eball on February 17, 2009, 01:40:54
Wow, thanks!
That was giving me all sorts of grief!!!

Quick question. Does it matter where I register the new instance of SuperPanel. Right now i have it in my "AddPanelCommand.as", which creates a new instance, sets its properties, registers it, then send it out with a notification. is that right?
:
var panel:SuperPanel = createSuperPanel(note.getBody().url);
registerMediator(new SuperPanelMediator(panel));
sendNotification(PANEL_CREATED, panel);


Title: Re: dynamic instantiation
Post by: Joel Hooks on February 17, 2009, 01:51:12
offtopic...
Which SuperPanel are you using? The constructor looks like the 'old' one.

http://brandonmeyer.net/blog/?p=7


Title: Re: dynamic instantiation
Post by: eball on February 17, 2009, 02:49:45
I am using: SuperPanel version : 1.5 author  : Wietse Veenstra

It is a good utility, but had some limitations. I was altering the code to increase some of its functionality.

Your SuperPanel 1.3 look great and appears to be a bit further along.
I think when your panel is in maximized mode, it should auto expand with it wrapper. (one of the things i added to the one i am working with)
Also, i agree that a taskbar or tabbed bar should manage all the opened taskbars when minimized or in maximized mode. That was going to be one of my next tasks.
Your "TODOs" look like they will add some nice functionality to the panel.
Maybe after I get some time, I will rework my project to use your SuperPanel, especially if you add your updates.
Thanks.


Title: Re: dynamic instantiation
Post by: Joel Hooks on February 17, 2009, 02:57:36
That actually isn't mine, but it is a 'live' project compared to the other. I've used Wietse's for some time, and it is very functional too after it is tweaked to allow styling.


Title: Re: dynamic instantiation
Post by: eball on February 17, 2009, 04:19:00
Like I said, Wietse's it is a good component. Not trying to step on anyones toes.
Just saying the other one seems to be closer to being a completed comp.