Title: Dynamically adding View components: where should I do it? Post by: schickm on June 23, 2008, 03:52:59 I'm working on a rather large application and so I dont want to actually embed mxml components inside of other mxml components manually. Instead I would just like to go
// TaskPanel is a view component So I'm thinking that I should do this stuff inside of a controller. Like say for instance I want to have a menu added dynamically I would create an controller called "ShowMenuCommand" and then do a sendNotification whenever I want it up. The problem is that I'm having trouble getting a reference to the main Application. I tried this: var appMed:ApplicationMediator = facade.retrieveMediator(ApplicationMediator.NAME) as ApplicationMediator; but I get this error on the second line above: Attempted access of inaccessible method app through a reference with static type com.onshored.planq.view:ApplicationMediator. Any ideas? Am I approaching this completely wrong? Title: Re: Dynamically adding View components: where should I do it? Post by: puremvc on June 23, 2008, 06:59:14 You're making a method call on the ApplicationMediator. app is probably defined as an implicit getter and therefore would be accessed like a property. Also, you should not retrieve the mediator and set this from a Command it breaks the encapsulation of the mediator. Instead, create the child object and send it as the body of a notification that the ApplicationMediator is interested in and let it call app.addChild.
-=Cliff> Title: Re: Dynamically adding View components: where should I do it? Post by: schickm on June 24, 2008, 08:28:51 Hah, that makes complete sense. I felt like I was doing something wrong when I was trying to do it from the controller. I now have it setup where my ViewPrepCommand sends a notification that the ApplicationMediator picks up on.
thanks for the quick and easy to understand reply Cliff! Your framework is the best for as3. |