Flash Tutorials, Samples, Resources, Greetings, Games
Home | About Us | Resources | Tutorials | Links | Games | Movies | Projects | Feedback | Contact Us
Tutorials
Here you'll get tutorials for all skill levels wheather you are a new user or an expert flash developer.

» Enter
Resources
In this section you'll get some small movie clips which can be used in your flash projects with flash components, flash action scripts .as files and some other stuff that will help you in your flash projects. You can also submit your work here. For submit details please checkout our Submit Page.

» Enter
Games
Play and download great flash games. If you have any flash game, please send us, we will put it with your name.

» Enter
Movies
Flash FLA movies to download.

» Enter
Home » Tutorials



   Advance Level - Using Alert Component

In this tutorial we will learn how to use the Alert Compoent of Flash MX 2004. I mean how we will call the Alert component and how its procedures are written in Action Script to set its parameters.

Open a new flash movie with your own choice of movie size. I have used the size 200X300. Open the Component Panel of Flash, drag the alert Component from Component Pallette and delete it from stage. I'm not Joking, we will use this component from our Library. We only need to have our Alert Component in our library so we need to drag our Alert Compoonent from the Component Pallete. You can check that the Linkage name of alert component in library is also "Alert", this we will use in our scripting.

Now again open the Component panel and this time drag the button Component which we will use to call the alert box. Set the label of this button what you want from the propertis panel of Flash MX 2004. From the same properties pannel give your button some Instance name, I have give it the name "mybtn". Now select the first frame and open the action pallete and write this script on first frame.

stop();
// import the Alert component from the Flash MX 2004 default set import mx.controls.Alert;
mybtn.onRelease = function()     {
Alert.show("See this is the Alert Message.");
        }


You have completed everything for a simple alert, just go and test your movie to see your result. You will see a simple alert box with a OK button and the message you have given without any title of the alert box. If you have some knowledge of java script, you should be aware what is the alert box title. Ok now we will generate Alert box with title as well as multiple buttons. First insert a dynamic text box where we will display which button you have clicked, and a new button Component to show advance Alert box. Give it a name (newbtn). Now open action pallete and add this script after previous script.

newbtn.onRelease = function()   {
Alert.show("This is new Alert Box.","This is Title", Alert.OK | Alert.YES | Alert.NO | Alert.CANCEL, this, aClickListner);
        }

aClickListner = function(btnClicked) {
  switch (btnClicked.detail)     {
    case Alert.OK:
       mytxt.text = "Ok button is Pressed" ;
       break;
    case Alert.YES:
       mytxt.text = "Yes button is Pressed" ;
       break;
    case Alert.NO:
       mytxt.text = "You have selected No button" ;
       break;
    default :
       mytxt.text = "Ok cancel this Action" ;
        }
}

So test your movie to see that you have finally done the Aert Box Component of Flash MX 2004. It is not much difficult as it seems to be.

Download Final Fla file