messagedialog.swf
General-purpose modal confirmation dialog used throughout Trove for purchase prompts, unlock confirmations, and other binary or multi-choice decisions. The game fills it with a message and one or more labeled response buttons at runtime.
Document/main class: MessageDialog (extends _kiwi.Core.UIComponent)
SWF-specific classes: 2
Main class: MessageDialog
MessageDialog is a data-driven modal panel. It starts invisible (configUI hides it) and reveals itself 100 ms after SETUP_COMPLETE is called, giving layout a chance to settle before the first paint. The game sends content through ExternalInterface callbacks: SET_MESSAGE provides the body text and an optional disclaimer, and ADD_RESPONSE appends a BtnGreen button. After all responses are added, SETUP_COMPLETE triggers the reveal timer and (on console) places controller-button images next to each response button.
Layout is done in draw(): KiwiTextUtil.colorize applies rich-text color markup to messageTextField, then centerResponses() measures all LabelButton children in buttonHolder, arranges them left-to-right, and calls resizeBG() to fit the background MovieClip. resizeBG also notifies the host via NOTIFY_RESIZED.
Public methods / setters
set message(param1:String) : void— stores the message and invalidatesDATA.setupComplete() : void— starts a 100 ms one-shotTimerto show the dialog; on console callsaddButtonImages()to position gamepad glyphs.
Key fields
background : MovieClip— panel backdrop; width and height are set dynamically.messageTextField : TextField— main body text; colorized byKiwiTextUtil.colorize.disclaimerIcon : MovieClip— warning icon shown alongside the disclaimer (hidden when no disclaimer text).disclaimerText : TextField— secondary fine-print text (e.g. purchase terms); visible only when text length > 0.buttonHolder : MovieClip— containsresponse_0(pre-placedBtnGreen) and dynamically addedBtnGreenchildren.numResponses : Number— count of response buttons added so far.nextResponseOffset : *— x-cursor for placing additional response buttons.BUTTON_SPACING : Number = 10— gap between buttons.BUTTON_MARGIN : Number = 30— horizontal padding inside each button.BUTTON_IMAGE_SPACING : Number = 27— extra room reserved for console gamepad-button images.BUTTON_LABEL_MARGIN : Number = 12— label inner margin.
Frame scripts / timeline
Stage 531×156, 24 fps, a single frame. None on MessageDialog. Button states are managed by BtnGreen's own four-frame timeline (frames 10, 20, 30, 40 — up/over/down/disabled states).
Runtime dependencies & integration
IggyFunctions.inIggy— gatesExternalInterfacecallbacks; in preview mode, a sample message and three buttons are injected directly.ExternalInterface.addCallback("SET_MESSAGE", setMessage)— receives(messageText:String, disclaimerText:String). A dialog with nothing to substitute arrives as its bare translation key (e.g.$TeleportToLair,$FriendsList_Remove), which Iggy resolves only when it is written intomessageTextField; dialogs built from a pattern with{0}slots arrive as finished text.ExternalInterface.addCallback("ADD_RESPONSE", addResponse)— receives(label:String, enabled:Boolean).ExternalInterface.addCallback("SETUP_COMPLETE", setupComplete)— signals that all responses have been added.ExternalInterface.call("MESSAGEDIALOG.RESPONSE", index)— fired on button click; sends the zero-based response index back to the game.ExternalInterface.call("NOTIFY_RESIZED", width, height)— called after background resize inresizeBG. The engine sizes and centres the dialog window from this report alone, and moves it on its own tick rather than during the call; the 100 ms reveal afterSETUP_COMPLETEkeeps the box hidden while that happens._kiwi.Util.KiwiTextUtil.colorize(tf, text)— parses color markup in message text.IsConsole()— controls extra button spacing and gamepad-glyph placement (btn_north,btn_south,btn_east).flash.utils.Timer(100, 1)+TimerEvent.TIMER_COMPLETE— deferred reveal after setup.MouseEvent.CLICKon eachBtnGreen—onResponseClickreadstarget.data(the response index) and calls back to the game.
Other game-specific classes
BtnGreen(extends_kiwi.Controls.LabelButton) — Embedsymbol11; four-state button clip (frames 10/20/30/40 = up/over/down/disabled) withstop()at each state boundary. Used as every response button in the dialog.
Notable logic
- The screen is built anew for every dialog: nothing ever clears
buttonHolder, and responses never carry over from one dialog to the next. addResponsereuses the pre-authoredbuttonHolder.response_0for the first button and creates newBtnGreeninstances for subsequent ones, each namedresponse_Nwithdata = Nfor click identification.- Button auto-sizing: if
textField.textWidth + BUTTON_MARGIN * 2exceeds the current button width,setActualSizewidens the button to fit the label. - On console with three responses: north/south/east gamepad glyphs are placed to the left of buttons 0/1/2 respectively; with two responses: south/east are used instead.
- The dialog is always horizontally centered:
buttonHolder.xandmessageTextField.xare both set tobackground.width / 2 - child.width / 2after each layout pass.