Once again, we go to the Components panel and click-drag an instance of the Message Box over onto the stage. Recall that we set up a separate layer to accept the box.
As you see here, this places a translucent "placeholder" image on the stage, and I've plopped it right over the two buttons. And as with all of our objects on the stage, start by giving this instance a name. I called mine errBox because it will mostly display error messages to the user.
If the Properties panel is not open, click the message box to open it. Now you can enter text you want to appear in the title bar of the message box and the message to display in the box. When you click on "icon" you get a choice of five icons that you may include in the message box.
Clicking on "OK" the default button, will open a window with which you may add additional buttons to the box along with their labels.
You may also add a "Click Handler" function that will be shared by all buttons, in which case you would need to pass a parameter to that function for each button. In my implementation here, it is not necessary that we have a click handler function, but simply use the default, which changes the visibility of the message box to false making it invisible.
In fact, that's how I've implemented the message box. It's always there, just invisible until needed. While it's invisible between calls, various parameters are changed to prepare it for the next call. Remember too, that it's disabled while invisible-- although it can also be disabled while visible as well, something you'll see in our code.
So let's go to a little scripting and see how all this fits together.
|» Level Intermediate|
Rating: 9 Votes: 81
|Tom Watson is a Flash developer currently residing in Nashville, Tennessee. He's been an independant contractor in the computer business since 1989, working on web projects since the web was introduced to the Internet in 1994.|
|Download the files used in this tutorial.|
|Download (569 kb)|
|More help? Search our boards for quick answers!|