开发者

Alert Box Class

I want to make a reusable Alert Box Class which will be instantiated on various screens of my Flex Project.

Can some tell me whats next in the code below, because am sort of lost regarding how to set the message and title and how to call the Class in my project?

Any help.

Thanks

package components
{
    import mx.controls.Alert;
    import mx.core.mx_internal;

    public class myAlertBox extends Alert
    {
        public function AlertBoza()
        {
       开发者_如何学C     super();

            var a:Alert;
        }

        override public static function show():void{


        }
    }
}


You do not need to extend Alert since the Alert.show() function is static. But you can set it as follows inserting a constructor for a message string and a class member. With that cou can just call the class with the constructor and show the alertbox.

package components { import mx.controls.Alert; import mx.core.mx_internal;

    public class myAlertBox
    {

            private var message:String;

        public function myAlertBox(message:String = "")
        {
            super();

            this.message = message;
        }

        public function show():void{

                    Alert.show(message);

        }
    }
}

In another class you can call:

var box:myAlertBox = new myAlertBox("Error");
myAlertBox.show();


If you just want to show a simple alert box, just use mx.controls.Alert directly as you can specify the title and the message show then:

import mx.controls.Alert;    
Alert.show("the message", "the title");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜