LoginSignup
0
0

More than 5 years have passed since last update.

Alertコントロールのカスタマイズ

Posted at

Alertコントロールとは、メッセージ、タイトル、「OK」「キャンセル」「はい」「いいえ」のボタン、アイコンを含むことができるポップアップダイアログボックスです。
Alertコントロールは、MXMLで作成できません。

1. 通常

スライド1.jpg

sample1.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="init()">
  <mx:Script>
    <![CDATA[
        import mx.controls.Alert;
        import mx.events.*;
        public function init():void{
            Alert.show("エラーメッセージ","エラー",Alert.YES,this,function(e:CloseEvent):void{}) 
        }
    ]]>
  </mx:Script>
</mx:Application>

通常のAlertコントロールをカスタマイズします。

2. カスタマイズ

スライド2.jpg

sample2.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="init()">
  <mx:Style>
    Alert{
        borderColor:#ffffff;
        backgroundColor:#ffffff;
        color:#000000;
    }
  </mx:Style>
  <mx:Script>
    <![CDATA[
        import mx.controls.Alert;
        import mx.events.*;
        [Embed(source='/assets/alert18x18.png')]
        private static var alert_confirm:Class;
        public function init():void{
            Alert.show("エラーメッセージ","エラー",Alert.YES,this,function(e:CloseEvent):void{},alert_confirm);
        }
    ]]>
  </mx:Script>
</mx:Application>

Styleタグで、Alertのスタイルを定義します。ここでは、ボーダ、背景色、フォントの色を変更しました。
次に[Embed]メタデータタグを利用して画像を埋め込みます。埋め込まれた画像は、alert_confirmというクラスとしてActionScriptから利用できます。


この記事は、以前ブログで公開していた記事、内容を再編集したものです。
ActionScript 1.0/2.0/3.0とFlex 3の内容が中心です。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0