This is sort of a follow-up to my previous tutorial on CGI Forms with Flash MX and the UI Components Set#2. I used the message box in that tutorial, but only with a single button. An email from a reader of that tutorial prompted me to take a closer look at the message box and how to use it with multiple buttons.
First if you don't have Components Set, go here. and get it. Install using the new version of Macromedia Exchange, which you can also download from that page.
Macromedia has issued very sparse documentation on these components, I guess leaving it up to us users to figure out how to use them. Perhaps one day they'll issue some tech notes or something, but in the meantime, here's what I've discovered. And I'll say up front, this may not be the most efficient way, but it works. I saw some hints along the way that makes me think there could be another way-- that there could be some methods that provide more direct access, but none that I could get to work.
First here's what my timeline looks like. Just four layers. One for "actions", one for "functions", one for the "message box", and one for a dynamic text box that will display some feedback.
This could all be done in a couple of frames, but I like a little room to move around in. Some of the layers could be combined as well, but again, I like to have my projects organized so that I know where everything is, and can find them six months from now!
Go to frame 5 in the "action" layer and add a keyframe. For the action in that frame add stop();.
Next, drag a message box from the "Components" panel on to the stage and open the "Properties" panel. Just fill what you want for "Title", "Icon", and "Message."
Now click on the icon on the "Buttons" line to open the dialog which allows you to add buttons to the message box. For this tutorial I added two more to the existing one, changing it's name in the process. My buttons are "Yes", "No", and "Maybe." Next type in a name for your "close handler." This can be any name that makes sense to you. I called my "myCloseHandler."
After filling in the properties, be sure and give this message box an instance name. We have to do this to be able to talk to it in action scripts. I called this one "myBox."
Next, lock and hide the message box. In the center of the stage, right where the message box displays, add a small dynamic text box. Give it an instance name (mine is "ansrBox"). For this test, we don't need to assign a variable, although you likely will in "real" applications.
|» Level Intermediate|
Rating: 7 Votes: 12
|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 (106 kb)|
|More help? Search our boards for quick answers!|