0 Replies Latest reply on Jan 22, 2007 12:19 PM by mltv

    Calling PopUpManager from a class in a library

    mltv Level 1
      I have a class for logins that I have put in a Flex Library Project.
      Part of the login is a popup form(mxml) I have created and is in the library.
      The problem I have is this line:
      loginPopUp = LoginForm(PopUpManager.createPopUp(this,LoginForm,true));
      The error I get is:
      1067: Implicit coercion of a value of type dataManagers:LoginManager to an unrelated type flash.display:DisplayObject.

      The parent “this” is no good since its parent should be the application that called the logon.
      Can I reference the caller from the LoginManager class I created to feed to popupmanager as the parent for the popup?

      The code in the app using the llibray that relates to this (to save space) is:
      ---------
      import dataManagers.LoginManager
      public var lm:LoginManager = new LoginManager();
      lm.initServices();
      ---------
      ---------
      //LoginManager.as

      package theLoginManager {
      import flash.events.Event;
      import mx.managers.PopUpManager;

      public class LoginManager {
      import LibraryViews.Login.LoginForm;
      public var loginPopUp:LoginForm;

      public function initServices() : void
      {
      Alert.show("Login start");
      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);
      displayLogin()
      }

      private function displayLogin():void{
      loginPopUp = LoginForm(PopUpManager.createPopUp(this,LoginForm,true));//THIS IS THE PROBLEM LINE
      loginPopUp.addEventListener("loginSuccessful", removeLoginPopup);
      }

      //Removes login form
      private function removeLoginPopup(event:Event):void{
      PopUpManager.removePopUp(loginPopUp);
      }
      }//End Class
      }//End Package
      ---------
      ---------
      //LoginForm.mxml
      <?xml version="1.0" encoding="utf-8"?>
      <mx:TitleWindow xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
      <mx:Form width="100%" height="100%" defaultButton="{loginBTN}">
      <mx:FormItem width="100%" label="Username" required="true">
      <mx:TextInput id="email"
      width="175" text="mltv"/>
      </mx:FormItem>
      <mx:FormItem width="100%" label="Password" required="true">
      <mx:TextInput id="password"
      displayAsPassword="true"
      width="175" text="nuffer"/>
      </mx:FormItem>
      <mx:VBox width="100%" horizontalAlign="center">
      <mx:Button id="loginBTN" label="Login" click="authenticateUser();" fillColors="[#80ff00, #80ff00]"/>
      </mx:VBox>
      </mx:Form>
      </mx:TitleWindow>