Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Welcome, Guest. Please login or register.
October 19, 2017, 01:48:27 AM
Home Help Search Login Register
News: Please DM @puremvc on Twitter to gain forum access. Spambots are why we can't have nice things.
Pages: [1]
Print
Author Topic: Vector cast to object and retrieval in sendNotification  (Read 3004 times)
saad
Sr. Member
****
Posts: 65


View Profile
« on: May 19, 2012, 02:39:36 AM »

It's an AS3 question, I'm having some problems in casting back to Vector, help please

Inside Proxy:
var leaderboardRowVOs:Vector.<LeaderboardRowVO> = new Vector.<LeaderboardRowVO>();
//populate routine
this.facade.sendNotification(ApplicationFacade.LEADERBOARD_SUCCESS, leaderboardRowVOs);

Inside Mediator
      override public function handleNotification(notification:INotification):void {
         switch(notification.getName()) {
            case ApplicationFacade.LEADERBOARD_SUCCESS:
               leaderboard.populate(notification.getBody() as Vector.<LeaderboardRowVO>);
               break;
         }
      }

Inside Component:

public function populate(leaderboardRowVOs:Vector.<LeaderboardRowVO>):void {
         trace(leaderboardRowVOs.length);
}
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW
« Reply #1 on: May 22, 2012, 07:01:23 AM »

I don't see anything wrong with this code except:

Code:
this.facade.sendNotification(ApplicationFacade.LEADERBOARD_SUCCESS, leaderboardRowVOs);

The 'this.facade' part is not necessary since the Proxy already has its own sendNotification() method, so just do this:
Code:
sendNotification(ApplicationFacade.LEADERBOARD_SUCCESS, leaderboardRowVOs);

Otherwise, I need a little more info. Are you getting a specific casting error or just not seeing the data? If  you set a breakpoint in the mediator on the 'leaderboard.populate' line and inspect variables, what does the note body contain?

-=Cliff>
Logged
Pages: [1]
Print
Jump to: