1 Reply Latest reply on Jan 22, 2007 12:40 PM by mltv

    Calling PopUpManager from a class in a library

      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();

      package dataManagers{
      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);

      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{
      }//End Class
      }//End Package
      <?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 width="100%" label="Password" required="true">
      <mx:TextInput id="password"
      width="175" text="nuffer"/>
      <mx:VBox width="100%" horizontalAlign="center">
      <mx:Button id="loginBTN" label="Login" click="authenticateUser();" fillColors="[#80ff00, #80ff00]"/>
        • 1. Re: Calling PopUpManager from a class in a library
          mltv Level 1
          I solved it by passing the parent when I called it from the parent project:

          and then created a var in the .as file:
          private var theCallingParent:DisplayObject;
          theCallingParent = theParent;

          Then used that variable when I called the popup:
          loginPopUp = LoginForm(PopUpManager.createPopUp(theCallingParent,LoginForm,true));

          Sorry to clog up the board.