As I'm working towards the conclusion of my first major PureMVC project, I thought I'd post a few reminders for myself (and anyone else who might stumble upon such posts) for things to watch out and not do.

The following is a little thing that I ran into with PureMVC. It is not noted here as a criticism of the framework or anything of that sort!

Flex Builder-created Mediators and Listing Notifications
When you create a new PureMVC mediator in Flex Builder 3 using the new ActionScript Class 'wizard', you extend the framework's Mediator class and implement its IMediator interface. Flex Builder provides and option, which you can check, to "Generate functions from inherited interfaces". If this options is selected, Flex Builder stubs out the functions from the interface, as you would expect.

The only problem is that it stubs out the method for listNotifications as follows:
public function listNotificationInterests():Array
return null;

There are two problems with this auto-generated code. First, if you are going to use this method in your mediator, you need to override it. This isn't a big deal because the compiler will throw an error letting you know you need to override it.

Second, this method has to return an array. It can be an empty array, but it must be an array and not a null value. This is not an error that will get caught in the compiler, so your application will run and then throw an error when you try to register your mediator.

If you include this method, and it's not required in mediators unless you want the mediator to subscribe to be sure to have it stubbed out as follows:

override public function listNotificationInterests():Array
return [];

In the scenario where you override the function but return null per the Flex Builder-generated code, the Flash player will throw an error when you go to instantiate (register in PureMVC) the Mediator in question, noting that it can't operate on a null value (Error 1009, if I recall).

The problem is that as the Mediator is being registered, the framework wants to know what notifications this mediator is subscribed to. At the least, it needs an empty array to determine that the Mediator is not interested in any notifications. The returned null value just doesn't do it!

It's little, I know, but it cost me a little time trying to track down a null object.


Oh thank goodness, I spend ages searching for 'PureMVC registerMediator null error in Flex' and finally found this!

Craig Kaminsky
@ashik: What sort of details are you looking for on SOAP Web Services? Consuming them in Flex? Creating them? Let me know & I'm sure I can help out.
redhat linux

this is ashik

I'm a beginner in flex develop and programming side ..

your post is useful for myself ..

i want details using SOAP webservice ...
Craig Kaminsky
Me, too! I've been using the current prerelease of FB 4 and it's going to be a huge improvement for us. Just wish I had it (FB4 alpha) earlier in this project. Oh well, next time right?!
Joel Hooks
Can't wait for FB4. It is going to allow for user-defined class templates. I make these changes blindly at this point :>