Articles Archive
Articles Search
Director Wiki

MUI Xtra

November 20, 1997
by Pat McClellan

Dear Multimedia Handyman
I like using the Alert command to bring up messages in my programs, but I wish I could add buttons other than OK to the dialog box. Do I have to use a Movie in a Window to get this?


"Click OK"

Dear Click

Like you, I use those alert boxes and have often wished that I could add more buttons -- to allow users an interactive choice. I have used MIAWs to simulate a multi-choice dialog box, but I had to create 2 versions of the dialog box movie so that it would look right on each platform. There's a much easier alternative now.

With Director 6, there's a new xtra called the MUI Xtra. (I think that stands for Macromedia User Interface.) It is located in the Media Support folder in the D6 Xtras folder. For complete details on its various functions, search on "mui" in the online Help. The great think about using this Xtra to generate your dialog boxes is that, like standard Alert boxes, the graphic look will adapt to the appropriate platform. Let's look at an example.

Imaging that you user has taken a quiz, but the score is below your acceptable minimum. You want to advise them that they should review the material, but you also want to allow them to continue. We need to create a property list of all the alert box options, such as the title of the dialog box, the text to be displayed, and the choice of buttons which will appear. A list of possible values appears in the Online Help documentation. For our example, we'll use Yes/No buttons, a title of "Quiz Score", and a "caution" icon to get their attention.

Here's the complete handler:

on failQuiz
  set myAlertPropList = [ #buttons : #YesNo,¬ 
    #message : "Your score needs improvement. ¬
    Would you like to review the material  now?",¬ 
    #icon : #caution, #title : "Quiz Score",¬
    #movable : TRUE]
  set myAlertBox = new (xtra "MUI") 
  -- instantiates the MUI object
  if objectP ( myAlertBox ) then 
  -- makes sure the object exists
    set result = Alert (myAlertBox, myAlertPropList
    case result of
      1 : -- the user clicked yes
        go to frame "review"
      2 : -- the user clicked no
        go to frame "next section"
    end case
  end if
end failQuiz

The command which actually prompts the dialog box to be displayed is:

Alert (myAlertBox, myAlertPropList)

This simply displays the box. When the user clicks a button, the result is returned to the handler. It's up to you to do something with that user input. In this example, I set a variable -- "result" -- equal to whatever the user clicks (1 for Yes, 2 for No.) Then I use a CASE statement to test the result & act accordingly.

The MUI Xtra limits you to certain button and icon choices, but still, the potential applications for dialog boxes are dramatically increased. Oh, one last note... don't forget to include a copy of the Xtra in the Xtras folder on your CD-ROM. And since this functionality uses the Xtra, it's not really practical for use with Shockwave.

Patrick McClellan is Director Online's co-founder. Pat is Vice President, Managing Director for Jack Morton Worldwide, a global experiential marketing company. He is responsible for the San Francisco office, which helps major technology clients to develop marketing communications programs to reach enterprise and consumer audiences.

Copyright 1997-2019, Director Online. Article content copyright by respective authors.