Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6837549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:29:25+00:00 2026-05-26T23:29:25+00:00

I have a remoteobject class that handles all interactive with my remote data service.

  • 0

I have a remoteobject class that handles all interactive with my remote data service. each time a call is made the dataservice checks that the user has a valid session. if they don’t it won’t run the requested method and it returns a fail. I can capture this fail in the fault handler. What I want to do it if it happens is push the login screen to the user.

I have tried the following

            var navigator:ViewNavigator;
            navigator.activeView.navigator.pushView(views.LoginScreen);

But this is not working and fails with Cannot access a property or method of a null object reference. which makes sense. so my question is how can I get a reference to the current running view navigator object and push the view?

Thanks

As requested here is the full remote object class

package remoting
{
import events.RemoteExceptionEvent;

import flash.events.*;

import mx.managers.CursorManager;
import mx.messaging.ChannelSet;
import mx.messaging.channels.AMFChannel;
import mx.rpc.events.FaultEvent;
import mx.rpc.remoting.RemoteObject;

import spark.components.ViewNavigator;

import views.FirstTime.ValidateUser;

/**
 * Super class for all remote services that contains some generic methods.
 */
public class RemoteService extends EventDispatcher

{
    private static var REMOTE_EXCEPTION:String = "Remote exception";
    private static var NO_MESSAGE:String = "10001";

    protected var remoteObject:RemoteObject;

    private var amfChannelSet:ChannelSet;

    /**
     * Constructor accepting an id and destination for the actual RemoteObject to create. An event listener
     * is added for exceptions.
     * @param id String representing the id of the new RemoteObject to create
     * @param destination String representing the destination of the RemoteObject to create
     * @param amfChannelId String representing the Channel of the RemoteObject to create
     * @param amfChannelEndpoint String representing the Endpoint URI of the RemoteObject to create
     */
    public function RemoteService( serviceId:String
                                   , serviceDestination:String
                                     , amfChannelId:String
                                       , amfChannelEndpoint:String
    ) 
    {
        // Create a runtime Channelset for given Channel ID and Endpoinr URI
        var amfChannel:AMFChannel = new AMFChannel(amfChannelId, amfChannelEndpoint);
        amfChannelSet = new ChannelSet();
        amfChannelSet.addChannel(amfChannel);

        // Create the remoteObject instance
        this.remoteObject = new RemoteObject(serviceId);
        this.remoteObject.channelSet = amfChannelSet;
        this.remoteObject.destination = serviceDestination;
        this.remoteObject.addEventListener(FaultEvent.FAULT,onRemoteException);
        this.remoteObject.setCredentials('test','test');

    }

    /**
     * generic fault event handler for all remote object actions. based on the received message/code an action
     * is taken, mostly throwing a new event.
     * @param event FaultEvent received for handling
     */
    public function onRemoteException(event:FaultEvent):void {
        trace('code : ' + event.fault.faultCode +
            ', message : ' + event.fault.faultString +
            ',detail : ' + event.fault.faultDetail);

            trace('fodun: ' + event.fault.faultDetail.indexOf("Authentication"));

        if (event.fault.faultDetail.indexOf("Authentication") > 0)
        {

            var navigator:ViewNavigator;

             navigator.activeView.navigator.pushView(views.LoginScreen);



        }
        else  if (event.fault.faultString == REMOTE_EXCEPTION) {
            EventDispatcher(
                new RemoteExceptionEvent(RemoteExceptionEvent.REMOTE_EXCEPTION,
                    "unknown problem occurred during a remote call : " + event.fault.message));
        } else if (event.fault.faultCode == NO_MESSAGE) { 
            EventDispatcher(
                new RemoteExceptionEvent(RemoteExceptionEvent.REMOTE_EXCEPTION,
                    event.fault.faultString));
        } else {

            EventDispatcher((
                new RemoteExceptionEvent(RemoteExceptionEvent.REMOTE_EXCEPTION,
                    "unknown runtime problem occurred during a remote call : " + event.fault.message)));
        }
    }
}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:29:26+00:00Added an answer on May 26, 2026 at 11:29 pm

    Accessing your view or whatever visual components from within a RemoteService class is not a good way to deal with MVC applications. What you want to do is to dispatch an event in your RemoteService class that basically says “authentication has failed”. Then, in your view, you’ll listen for this event and interpret it as a need to display the login screen. See ?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I have a class that is a remote object and I implemented methods.
I'm encapsulating a call to a remoting service in my own RemoteObject class. This
I have several clients all referencing the same remote object through RMI, and I
I have a NSMutableArray that contains all the calendars on my system (as CalCalendar
I have an as3 class that I use for communicating with my Zend_AMF endpoint:
It's the first time I use java Rmi*. I have a custom class which
I have class Item and class List (which has an NSMutableArray). Every time class
I am trying to create class that will handle multiple downloads at same time
I have this function return [remoteObject objectForKey:key]; which should return an object that is
I have an app with the following basic architecture: A windows service (Service) that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.