0 Replies Latest reply on Jan 23, 2007 6:31 AM by mltv

    How to refer to the calling page's assets from a class in included library.

    mltv
      I have a login class that is in a library included in my project.
      The project calls the class:
      import dataManagers.LoginManager;
      public var lm:LoginManager = new LoginManager();
      lm.initServices(this);



      Here is the class that is being called:

      package dataManagers {
      import models.users;
      import mx.rpc.events.ResultEvent;
      import flash.events.MouseEvent;
      import flash.events.Event;
      import mx.managers.PopUpManager;
      import mx.rpc.remoting.RemoteObject;
      import mx.rpc.events.FaultEvent;
      import mx.controls.Alert;
      import mx.utils.ObjectUtil;
      import flash.display.DisplayObject;
      import models.users;
      public class LoginManager {
      import LibraryViews.Login.LoginForm;
      private var appCFC:RemoteObject;
      private var loginPopUp:LoginForm;
      private var theCallingParent:DisplayObject
      public var theUserObject:users;

      private function server_fault(event:FaultEvent):void{
      Alert.show(ObjectUtil.toString(event.fault) );
      }
      public function initServices(theParent:DisplayObject): void{
      theCallingParent = theParent;
      appCFC = new RemoteObject("ColdFusion");
      appCFC.source = "CFC.Users.usersGateway";
      appCFC.addEventListener(FaultEvent.FAULT, server_fault);
      appCFC.init.addEventListener(ResultEvent.RESULT,init_result);
      appCFC.getById.addEventListener(ResultEvent.RESULT,getById_result);
      appCFC.init();
      }
      public function init_result(event:ResultEvent):void{
      if(event.result == 0){
      displayLogin();
      }else{
      appCFC.getById(event.result);
      }
      }
      private function displayLogin():void{
      loginPopUp = LoginForm(PopUpManager.createPopUp(theCallingParent,LoginForm,true));
      loginPopUp.addEventListener("loginSuccessful", removeLoginPopup);
      }
      //Removes vendor form
      private function removeLoginPopup(event:Event):void{
      theUserObject = loginPopUp.detailLoginObject;
      PopUpManager.removePopUp(loginPopUp);
      }
      public function getById_result(event:ResultEvent):void{
      if(event.result.ID != 0){
      theUserObject = event.result as users;
      }
      }
      }//End Class
      }//End Package




      The class then handles the entire login and has to return an object representing the user info from the database.

      The problem I am having is referring to the parent page to pass the “user Object” back.
      My work around for calling the popup by passing the Display object when I call the class does not work for passing the “User Object” back.