calling a popup by passing his name to a function

Ask a Question related to Macromedia Flex General Discussion, Design and Development.

  1. #1

    Default calling a popup by passing his name to a function

    Hi! I'm new to Flex.

    I have created with Flex 2 popups (which are TitleWindows):

    popup1.mxml and popup2.mxml

    Is there a way to write a function like this:

    PHP Code:
    public function openPopup(myPopup:String){

    //here the code to take the string myPopup (which can be popup1 or popup2) and
    create the popup...
    ??? I really don't know how to do this

    PopupManager.createPopup (this, ???, true);

    }


    Thanks in advance.

    Davide

    Davide C Guest

  2. Similar Questions and Discussions

    1. Calling a function within a function registered to an event
      Hey, Just registered and tried to search through the forum for a solution to my problem, but I haven't found anything that could help me. I've...
    2. Calling from ASP to .Net passing Recordset
      Hi, I'm using a "classic" asp-page and a .net-component which I want to call passing a Recordset as a parameter. I have a reference to ADODB in...
    3. Passing a variable to a package function vs. a local function
      I'm a bit new to this so please bear with me... I've written a script that uses CGI.pm something like this: use CGI::Carp qw(fatalsToBrowser);...
    4. Function calling from url
      Good morning! I would like to call a function from a <FORM>'s ACTION attribute. This is what I'm trying to do: <FORM...
    5. Function/Global var to return name of calling function?
      I'm sure I saw this somewhere but can't remember where and can't find it now... Is there a PHP function or global variable that will return name...
  3. #2

    Default Re: calling a popup by passing his name to a function

    take a look at:
    [url]http://www.onflex.org/ted/2007/11/creating-class-instances-dynamically.php[/url]

    essentially you'll be using ApplicationDomain.currentDomain.getDefinition
    method call as the second parameter to craetePopu method.

    atta707 Guest

  4. #3

    Default Re: calling a popup by passing his name to a function

    Thank you very much!

    Davide
    Davide C Guest

  5. #4

    Default Re: calling a popup by passing his name to a function

    Just another question about this:

    I implemented the popup as a mxml component in the drectory
    src/popups/pop_login.mxml. And "hasDefinition" doesn't seem to work in that
    case...Is there a way to do that WITHOUT implementing the popup as a class?

    Thanks.

    Davide


    Davide C Guest

  6. #5

    Default Re: calling a popup by passing his name to a function

    So you have it working now?
    atta707 Guest

  7. #6

    Default Re: calling a popup by passing his name to a function

    Not yet.., I mean: what I have now is:

    var login:pop_login=pop_login(PopUpManager.createPopUp ( this, pop_login ,
    true));

    where pop_login is a component. I don't know how, but Flex seem to find it and
    use it as a class. But if I do the same thing this way:

    var thePop:Class =
    Class(ApplicationDomain.currentDomain.getDefinitio n(popUpName));

    where popUpName is the filename (without extension) of the component
    (pop_login.mxml , in the dir src/popups/) that I pass as string, the function
    returns always false...

    Sorry, I'm new to Flex, maybe it is a bit confused...



    Davide C Guest

  8. #7

    Default Re: calling a popup by passing his name to a function

    No, I tried but it does not work. I don't know how to do this with mxml components. it seems that
    ApplicationDomain.currentDomain.hasDefinition always returns false...

    Davide C Guest

  9. #8

    Default Re: calling a popup by passing his name to a function

    What I need is just a sort of "Factory Pattern" where, according to what I pass as a string, it instantiates the class with that name.
    Davide C Guest

  10. #9

    Default Re: calling a popup by passing his name to a function

    SOLVED!!!

    The problem was this:
    You have to specify the entire path to the MXML file:
    hasDefinition("components.popups."+popUpName)
    Now it works PERFECTLY!.

    Davide C Guest

  11. #10

    Default Re: calling a popup by passing his name to a function

    Thanks for sharing it back.
    atta707 Guest

  12. #11

    Default Re: calling a popup by passing his name to a function

    Just another NOTE:

    The code above works ONLY if you reference the classes somewhere in the code.
    I mean:

    public var: popLogin:pop_login; and so on...

    This is not good at all.

    So my question is: how you can REFERENCE (not import) an entire set of classes
    (components, actually) in a project?



    Davide

    Davide C Guest

  13. #12

    Default Re: calling a popup by passing his name to a function

    Use modules.

    Tracy
    ntsiii Guest

  14. #13

    Default Re: calling a popup by passing his name to a function

    [q]Originally posted by: ntsiii
    Use modules.

    Tracy[/q]

    Hi Tracy,
    it does not work...maybe I'm missing something, but I have created a module
    and tried to load (as popup) dinamically...but the result is the same. I have
    to reference it before doing that:

    public var myModule:TestModule; //This is what I would like to AVOID.

    then I can use this:

    var myClass:Class =
    ApplicationDomain.currentDomain.getDefinition("pop ups.testModule") as Class;
    var myPopup:TitleWindow =
    TitleWindow(PopUpManager.createPopUp(this,myClass, true));

    Davide

    Davide C Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139