views:

9

answers:

1

I have a mediator that I've registered for a navigation page:

facade.registerMediator(new NavPageMediator(viewComponent));

I'm trying to retrieve that mediator on another page like so:

var navPageMediator:NavPageMediator = facade.retrieveMediator(NavPageMediator.NAME) as NavPageMediator;

However, that statement returns null. If I try to cast it using the NavPageMediator(facade.retrieveMediator(NavPageMediator.NAME)) syntax instead, I get a

TypeError: Error #1034: Type Coercion failed: cannot convert com.website.mvc.view.page::NavPageMediator@237560a1 to com.website.mvc.view.page.NavPageMediator.`

I can't, for the life of me, understand why NavPageMediator@237560a1 would be unable to convert to NavPageMediator, nor what happened in between registering the mediator and retrieving it that caused this. Especially since trace(new NavPageMediator() as NavPageMediator); returns [object NavPageMediator].

Incidentally, and this may be part of my problem, I don't understand what the @hash at the end of the object is (@237560a1). Is it simply an internal identifier for that class instance?

Edit: Left a bit of important info: The SWF in which I instantiate and register the mediator is separate from the SWF in which I try to retrieve it.

A: 

Figured it out. It turned out to be an ApplicationDomain issue. Assigning both SWFs (the registrant and the retriever) to the same domain solved the issue.

Additionally, I'm pretty sure the @hash at the end of the class name is an internal reference to the ApplicationDomain to which the class belongs. So NavPageMediator@237560a1 was in a different domain than NavPageMediator (why there was no hash on the second one I'm still not sure; that would have made things a bit clearer).

Beco