簡體   English   中英

Flex中使用popupmanager時的隱式強制

[英]implicit coercion when using popupmanager in flex

我不得不重新格式化我的問題,因為我意識到我使用了不正確的flex方法。 但是仍然發生類似的問題:

        private function passForm():void {


            PopUpManager.addPopUp(passTitleWindow, this, true);
            PopUpManager.centerPopUp(passTitleWindow);


        } 

                            <s:Button includeIn="Detail" x="10" y="329" 
                                  id= "btn1"
                                  label="Pass"
                                  click="passForm()" 
                                  visible="{hasScreen}" />

我單擊,彈出窗口不顯示。

您無法根據其id實例化一個項目。 使TitleWindow進入另一個類並實例化它。

PassTitleWindow.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow
    xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns:mx="library://ns.adobe.com/flex/mx"
    title="Pass"
    layout="vertical"
    width="480"
    height="240"
    titleStyleName="titleText"
    backgroundColor="white"
    backgroundAlpha="1.0"
    borderColor="white"
    borderAlpha="1.0"
    cornerRadius="0"
    showCloseButton="true"
    implements="mx.core.IDataRenderer">

    <fx:Script>
        <![CDATA[

            private var _data:Object;
            [Bindable(event="dataChange")]
            /**
             *  implementing mx.core.IDataRenderer.
             *  Set this value from outside
             */
            public function get data():Object
            {
                return _data;
            }

            /**
             *  @private
             */
            public function set data(value:Object):void
            {
                if (_data == value) 
                    return;
                _data = value;
                dispatchEvent(new Event("dataChange"));
            }
        ]]>
    </fx:Script>

    <mx:Text text="Please fill out the following criteria and then click continue."
        width="100%"
        styleName="headingText"/>

    <mx:Form x="-12" y="150" id="passView">

        <mx:FormItem label="Age" >
            <s:TextInput id="ageTextInput" "@{data.age}"/>
        </mx:FormItem>
        <mx:FormItem label="Grade" >
            <s:TextInput id="gradeTextInput"/>
        </mx:FormItem>

    </mx:Form>

</mx:TitleWindow>

SampleApp.mxml

<?xml version="1.0" encoding="utf-8"?>
<s:Application 
    xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns:mx="library://ns.adobe.com/flex/mx"
    creationComplete="creationCompleteHandler()">

    <fx:Script>
        <![CDATA[

            import mx.managers.PopUpManager;

            protected var passWindow:PassTitleWindow = new PassTitleWindow;

            protected function creationCompleteHandler():void
            {
                createForm();
            }

            protected function createForm():void
            {
                passWindow = PopUpManager.createPopUp(this, PassTitleWindow, true) as PassTitleWindow;
                passWindow.data = studentGrid.selectedItem;
                PopUpManager.centerPopUp(passWindow);
            }
        ]]>
    </fx:Script>

</s:Application>

希望有幫助,蘭斯

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM