Professional Web Applications Themes

how to pass variable in TitleWindow - Macromedia Flex General Discussion

hi all , can we pass variable in TitleWindow ??? where i put my variable??? mx.managers.PopUpManager.createPopUp(_root, inVoice,true, {deferred: true});...

  1. #1

    Default how to pass variable in TitleWindow

    hi all ,

    can we pass variable in TitleWindow ???

    where i put my variable???

    mx.managers.PopUpManager.createPopUp(_root, inVoice,true, {deferred: true});


    bhavin_kp Guest

  2. #2

    Default Re: how to pass variable in TitleWindow

    Let's say you want to pop up a window with a name in it. Define an MXML file to
    display it (call it Sample.mxml), based on TitleWindow and include the name as
    a variable:

    <mx:TitleWindow ...>
    <mx:Script>
    var userName:String;
    </mx:Script>
    <mx:Label text="Hello {userName}" />
    </mx:TitleWindow>

    Now you want to pop up the window and pass in a name:

    mx.managers.PopUpManager.createPopUp( parentApplication, Sample,
    {userName:"Kevin"});

    So you define a variable in your MXML file for the TitleWindow, then pass its
    value along with other initialization values in the initProps parameters to
    createPopUp.


    peterent Guest

  3. #3

    Default Re: how to pass variable in TitleWindow

    Since this gets asked very often, I have created a full sample, listing below,
    that uses three different ways to pass data into a title window.

    It uses the initobj, as in Peter's example to pass in built in objects plus
    two user defined objects, one is a simple string.

    The other is a reference to the main application that can be used for binding.
    Note the variable that holds the application reference is typed to the name of
    the application. this is critical for binding to work correctly.

    It also uses the reference to the created pop-up to set a variable in the
    title window.

    Hope it helps.
    Tracy



    ****The title window component
    <?xml version="1.0" encoding="utf-8"?>
    <mx:TitleWindow xmlns:mx="http://www.macromedia.com/2003/mxml"
    closeButton="true"
    click="this.deletePopUp();"
    creationComplete="initComponent()">
    <mx:Script><![CDATA[
    public var mainApp:TitleWindowDataTest = null; //will be populated by passed
    in initobj
    public var gsMyString:String; //will be populated by passed in object
    public var gnMyNumber:Number; //will be populated by reference in main
    app

    private function initComponent():Void
    {
    lblCalc.text = (9 * gnMyNumber);
    }
    ]]></mx:Script>
    <mx:HBox >
    <mx:Label text="{gsMyString}" width="150" />
    <mx:Label text="Bound to local variable populated by initobj argument" />
    </mx:HBox >
    <mx:HBox >
    <mx:Label id="lblMyNumber" text="{gnMyNumber}" width="150"/>
    <mx:Label text="Bound to local variable populated by reference in main app"
    />
    </mx:HBox >
    <mx:HBox >
    <mx:Label text="{mainApp.gsBindMe}" width="150"/>
    <mx:Label text="Bound to main app variable via passed in reference" />
    </mx:HBox >
    <mx:HBox >
    <mx:Label id="lblCalc" width="150"/>
    <mx:Label text="Calculated value set by initialize event handler" />
    </mx:HBox >
    </mx:TitleWindow>

    ***The test application
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"
    horizontalAlign="left">
    <mx:Script><![CDATA[
    public var gsBindMe:String = "Change me!" ; //
    import mx.containers.TitleWindow;
    import mx.managers.PopUpManager;
    private function showTitleWindow():Void
    {
    var oInitObj:Object = new Object();
    oInitObj.title = "Title Window Data"; //built-in property
    oInitObj.width = 600; //built-in property
    oInitObj.height = 200; //built-in property
    oInitObj.mainApp = this; //user-added property. reference to main app
    oInitObj.gsMyString = tiMyString.text; //user-added property. will contain
    value of text input
    var titleWindowInstance:Object =
    TitleWindow(PopUpManager.createPopUp(this,
    TitleWindowData,
    false,
    oInitObj,
    false)); //instantiate and show the title window

    titleWindowInstance.centerPopUp(this)
    titleWindowInstance.gnMyNumber =
    pFloat(tiMyNumber.text); //titleWindowInstance must be Object to use this
    }
    ]]></mx:Script>
    <mx:HBox >
    <mx:Label text="MyString:" width="100" />
    <mx:TextInput id="tiMyString" text="my string" />
    </mx:HBox >
    <mx:HBox >
    <mx:Label text="MyNumber:" width="100"/>
    <mx:TextInput id="tiMyNumber" text="99"/>
    </mx:HBox >
    <mx:HBox >
    <mx:Label text="Bind Me" width="100"/>
    <mx:TextInput id="tiBindMe" text="{gsBindMe}"
    change="gsBindMe = tiBindMe.text"/>
    </mx:HBox >
    <mx:Button label="ShowTitleWindow{newline}Non-Modal"
    click="showTitleWindow()"/>
    </mx:Application>

    ntsiii Guest

Similar Threads

  1. The variable won't pass
    By weswhite7 in forum Coldfusion - Advanced Techniques
    Replies: 2
    Last Post: July 8th, 06:10 AM
  2. How to pass a variable to a second page
    By chill84 in forum Macromedia ColdFusion
    Replies: 5
    Last Post: May 18th, 04:49 AM
  3. Login needs to pass variable
    By *thirtysixsquares* in forum Macromedia ColdFusion
    Replies: 1
    Last Post: April 4th, 11:03 AM
  4. How to pass a variable to .t file
    By Rajesh Dorairajan in forum PERL Beginners
    Replies: 3
    Last Post: November 4th, 07:14 PM
  5. [PHP] Still can't pass variable through url
    By Joe Harman in forum PHP Development
    Replies: 1
    Last Post: August 8th, 06:58 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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