0

非常に多くのアラートメッセージが含まれているアプリケーションを開発しました。画面の特定の位置にすべてのアラートメッセージを表示したいと思います。次のコードを試しましたが、個々のアラートメッセージに対して機能します。アプリケーションのすべてのアラートメッセージに適用できる方法はありますか?

  myAlert = Alert.show('Hello World');
  PopUpManager.centerPopUp(myAlert);
  myAlert.x = 0;
  myAlert.y = 0;

前もって感謝します

4

1 に答える 1

0

www-flextras.comが提案しているように、このようなクラスを使用して、アラートメッセージを配置するためのロジックを配置できます。

CREATION_COMPLETEアラートの位置を設定する前に、イベントを待つ必要があります。_alert.move(_nextX, _nextY)次の例でも使用できることに注意してください。

package
{
    import flash.display.Sprite;

    import mx.controls.Alert;
    import mx.core.IFlexModuleFactory;
    import mx.events.FlexEvent;

    public class MyAlertFactory
    {
        private static const MAX_WIDTH:uint = 320;
        private static const MAX_HEIGHT:uint = 280;

        private static var _nextX:int = 0;
        private static var _nextY:int = 0;

        public static function show(text:String, title:String = "",
                                    flags:uint = 4, parent:Sprite = null,
                                    closeHandler:Function = null,
                                    iconClass:Class = null,
                                    defaultButtonFlag:uint = 4,
                                    moduleFactory:IFlexModuleFactory = null):Alert {

            var alert:Alert = Alert.show(text, title, flags, parent,
                closeHandler, iconClass, defaultButtonFlag, moduleFactory);
            alert.addEventListener(FlexEvent.CREATION_COMPLETE, handleAlertCreation);

            return alert;
        }

        private static function handleAlertCreation(event:FlexEvent):void
        {
            _nextX = (_nextX + 20) % MAX_WIDTH;
            _nextY = (_nextY + 15) % MAX_HEIGHT;

            var alert:Alert = Alert(event.currentTarget);
            alert.x = _nextX;
            alert.y = _nextY;
            alert.removeEventListener(FlexEvent.CREATION_COMPLETE, handleAlertCreation);
        }
}
于 2013-03-17T00:53:32.097 に答える