0

ユーザーがボタンをクリックするとデータベースにクエリを送信する Flex アプリケーションがあります。クエリは重い可能性があり、最大で 1 分かかる可能性があるため、イベントがデータベースから返された後にのみ閉じるアラートを表示したいと考えています (ユーザーが自分で閉じることはできません)。Flexで可能ですか?それ、どうやったら出来るの?

関数 sendQuery() と dataEventHandler() があります。アラートを表示するには sendQuery() に、DB からデータが送信された後にアラートを閉じるには dataEventHandler() にコードを入れる必要があると思いますが、ユーザーがアラートを「閉じられないようにする」にはどうすればよいですか?

4

5 に答える 5

1

組み込みのFlexAlertクラスには、常に何らかのタイプの閉じるボタンがあります。

ただし、独自のコンポーネントを作成できない理由はありません。次に、PopUpManagerを使用して開いたり閉じたりします。

于 2012-08-01T15:39:47.240 に答える
0

アイデアとして、カスタムアラートを作成できます。

  1. アラートを表示
  2. アプリケーションを無効にします。
  3. アラートを非表示にします。
  4. アプリケーションを有効にします。

警告の例:

<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" 
         xmlns:s="library://ns.adobe.com/flex/spark" 
         xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300"
         creationComplete="onCreationComplete(event)">

    <s:Rect>
        <s:fill>
            <s:SolidColor color="0xFFFFFF"/>
        </s:fill>
        <s:stroke>
            <s:SolidColorStroke />
        </s:stroke>
    </s:Rect>

    <s:Label text="Please Wait..."/>

    <fx:Script>
        <![CDATA[
            import mx.core.FlexGlobals;
            import mx.events.FlexEvent;
            import mx.managers.PopUpManager;
            public static function show():void
            {
                PopUpManager.createPopUp(FlexGlobals.topLevelApplication);      
            }

            public static function hide():void
            {
                PopUpManager.removePopUp(this);
                FlexGlobals.topLevelApplication.enabled = true;
            }

            protected function onCreationComplete(event:FlexEvent):void
            {
                PopUpManager.centerPopUp(this);
                FlexGlobals.topLevelApplication.enabled = false;
            }
        ]]>
    </fx:Script>
</s:Group>

使用法:

YourAlert.show();

YourAlert.hide();
于 2012-08-02T11:12:40.513 に答える
0

次のコードはあなたを助けるかもしれません…(解決策の1つ...)あなたは私が解決策1と解決策2を作ったのを見つけることができます…あなたはそれのどれでも使うことができますそして3番目の解決策はあなた自身のカスタムコンポーネントを作成することです。以下のコードを見つけてください…。以下のロジックを使用して問題を解決できます。タイマーを使用してデータが受信されたかどうかを確認するか、カスタムイベントをディスパッチしてupdateAlertPosition関数を呼び出すことができます。

それが役立つことを願っています:-

<?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" minWidth="955" minHeight="600"
               >
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>

    <fx:Script>
        <![CDATA[
            import mx.controls.Alert;
            import mx.events.CloseEvent;
            import mx.managers.PopUpManager;

            private var minuteTimer:Timer;
            private var alert:Alert;

            private var displayInitialText:String = "Data Not Received, Please wait...."; 
            private var displayDataReveivedText:String = "Data Received...";

            private function timerInit():void
            {
                //Logic to check if data Received.
                minuteTimer = new Timer(3000);
                minuteTimer.addEventListener(TimerEvent.TIMER, updateAlertPosition);
                minuteTimer.start(); 
            }

            private function updateAlertPosition(event:Event = null):void {
                minuteTimer.stop();
                //Solution 1
                //add your flag here if y you want to check if data is received or not
                //if(Data Received)
                alert.mx_internal::alertForm.mx_internal::buttons[0].enabled = true;
                alert.mx_internal::alertForm.mx_internal::buttons[1].enabled = true;
                alert.mx_internal::alertForm.mx_internal::textField.text = displayDataReveivedText;
                //Solution 2
                //alert.enabled = true;
                //If you want to remove it automatically
                //closeAutomatically();
            }

            private function closeAutomatically():void
            {
                PopUpManager.removePopUp(alert);
            }

            private function clickHandler():void
            {
                //Start Timer
                timerInit();
                //Solution 1
                alert = Alert.show(displayInitialText, "Alert", Alert.OK|Alert.CANCEL,this,alertCloseHandler);
                alert.mx_internal::alertForm.mx_internal::buttons[0].enabled = false;
                alert.mx_internal::alertForm.mx_internal::buttons[1].enabled = false;
                //Solution 2
                //alert.enabled = false;
            }

            private function alertCloseHandler(event:CloseEvent):void
            {
                if(event.detail == Alert.CANCEL)
                {
                    //Some Code on close
                }
                else
                {
                    //Some Code on OK
                }

            }
        ]]>
    </fx:Script>

    <s:Button label="Show Alert" x="100" y="100" click="clickHandler()"/>
</s:Application>
于 2012-08-02T05:16:37.967 に答える
0

アプリケーション全体をカバーする 0 ~ 0.2 のアルファ形状を作成し (おそらく resizeevents をリッスンする必要があります)、カスタム パネルをその中央にメッセージとともに追加します。

于 2012-08-02T10:34:03.807 に答える
0

@Alex、私はあなたのコードを使用しましたが、いくつかのエラーがあったため、少し変更しました:

<?xml version="1.0" encoding="utf-8"?>
<s:Group 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()" width="100%" height="100%">
    <fx:Script>
        <![CDATA[

            import mx.core.FlexGlobals;
            import mx.core.UIComponent;
            import mx.managers.PopUpManager;

            ///////////////////////////////////////
            //// public functions - my group is ImageViewer.mxml component


            public static function show():ImageViewer {
                return PopUpManager.createPopUp(FlexGlobals.topLevelApplication as DisplayObject, ImageViewer) as ImageViewer;
            }

            public function hide():void {
                PopUpManager.removePopUp(this);
                FlexGlobals.topLevelApplication.enabled = true;
            }


            ////////////////////////////
            //// component events

            private function creationCompleteHandler():void {
                PopUpManager.centerPopUp(this);
                FlexGlobals.topLevelApplication.enabled = false;
            }
            ]]>
    </fx:Script>
</s:Group>

そして、次のように呼び出します。

var imageviewer:ImageViewer = ImageViewer.show();
//imageviewer.imageURL = _value_dto.value;
于 2013-03-04T12:17:36.687 に答える