dropprompt.swf
A modal quantity-picker dialog that the game opens for every "how many" question about a stack: dropping an item on the ground, moving it between bags, or composting it at the deconstructor. It displays a prompt message, a numeric text input, +/− step buttons, Min/Max buttons, and Confirm/Cancel buttons. Full console support is included with D-Pad, LT/RT, and on-screen keyboard hints.
Document/main class: DropPrompt (extends _kiwi.Core.UIComponent)
SWF-specific classes: 10
Main class: DropPrompt
DropPrompt is the root component for the item-drop confirmation panel. The constructor binds two frame scripts (frames 0 and 10) and applies component inspector defaults to the three button/input widgets, then defers to UIComponent.configUI(). During configUI() all button event listeners are wired, two ExternalInterface callbacks are registered (setMax, setQuantity), and six additional callbacks are registered that allow the C++ game engine to invoke the same handlers the buttons use. A draw() override re-clamps the quantity property whenever DATA is invalidated (triggered by any non-backspace/delete key press in the text field).
The setMax() method is the main layout driver: it dynamically repositions all controls horizontally so the control row is centered within bg, accounting for the variable digit-width of the max quantity. Console-specific controls (LT, RT, D-Pad, keyboard button) are included in the layout calculation only when IsConsole() is true.
Public methods
get quantity() : Number— reads and parsesquantityTextInput.text; returns 0 on NaN.set quantity(value:Number) : *— clampsvalueto[0, maxQuantity], updates the text input, and togglesdropButton.enabled(> 0),incrementButton.enabled(< max), anddecrementButton.enabled(> 0).set message(text:String) : void— setspromptMessage.text. Written by the engine as a property assignment (not a callback) with the question:$DropPrompt_DropQuestion("How many would you like to drop?"),$DropPrompt_MoveQuestion("…to move?") or$Deconstructor_CompostDropPrompt("…to compost?"). It can arrive either as the raw key or as already-translated text.set acceptButtonLabel(text:String) : void— overridesdropButton.label. Also an engine property assignment, and the only thing that tells a drop from a move:$DropPrompt_Confirm("DROP") or$DropPrompt_MoveConfirm("MOVE"), again as a raw key or translated text.setMax(max:Number) : void— the stack size; the first call the engine makes when the prompt opens. StoresmaxQuantity, resetsquantityto 1, dynamically resizesquantityTextInput.bgto fit the digit count (12 px per char), and repositions all controls horizontally centered inbg. On console, also layouts D-Pad vertically centered on the input and stacks increment/decrement above/below it.setQuantity(value:Number) : void— clamps and appliesvalue, then focusesquantityTextInput.textFieldand selects all text.
Key fields
quantityTextInput : TextInput— editable numeric field;restrict="0-9",maxChars=4at authoring time (setMaxthen sets it to the max's digit count).dropButton : LabelButton— confirm button; default label key"$DropPrompt_Confirm".cancelButton : LabelButton— cancel button; default label key"$DropPrompt_Cancel".incrementButton : BaseButton— steps quantity up by 1.decrementButton : BaseButton— steps quantity down by 1.minButton : BaseButton— jumps tomin(1, maxQuantity).maxButton : BaseButton— jumps tomax(0, maxQuantity).promptMessage : TextField— static prompt text shown above the controls.bg : MovieClip— panel background; itswidthis the centering reference for dynamic layout.dpad_console : btn_console_dpad_updowneast— D-Pad hint icon shown on console.button_console_keyboard : btn_console_keyboard— on-screen keyboard button icon; on NX (IsNX()) this is hidden and replaced bytxtKeyboardButtonwith the translated string"$Keyboard_Desc_nx".button_console_south : btn_console_south— south-button (A/Cross) hint icon.button_console_east : btn_console_east— east-button (B/Circle) hint icon.button_console_lt : btn_console_lt— left trigger hint icon.button_console_rt : btn_console_rt— right trigger hint icon.txtKeyboardButton : TextField— NX-only text replacement for the keyboard button icon.maxQuantity : Number = 1— upper bound for the quantity field.
Frame scripts / timeline
- Frame 1 (
frame1, labelPC):stop()— default layout; placesbg, the buttons,quantityTextInputandpromptMessage. - Frame 11 (
frame11, labelConsole):stop()— adds the console hint icons (button_console_lt/rt/south/east/keyboard,dpad_console) andtxtKeyboardButton, and re-placespromptMessage; these children exist only on this frame (controls repositioned bysetMaxat runtime regardless of frame).
Runtime dependencies & integration
ExternalInterface.addCallbackregistrations:"setMax","setQuantity","onIncrement","onDecrement","onMinQuantityClicked","onMaxQuantityClicked","onDrop","onCancel"— the sixon…names are the controller bindings: the engine calls them when the matching pad button is pressed, reaching the same handlers as the mouse.ExternalInterface.calloutbound:"DropConfirm"(quantity)— fired on drop button click or Enter key, only when quantity is valid and<= maxQuantity."Cancel"()— fired on cancel button click.
IggyFunctions.translate("$Keyboard_Desc_nx")— NX platform keyboard hint string.com.kiwi.Constants.KeyCodes— used to detectENTER(submit) andBACKSPACE/DELETE(skip invalidation).InvalidationType.DATA— invalidation type used to schedule quantity clamping after key input.IsConsole()/IsNX()— platform guards; console path adds LT/RT/D-Pad to the layout; NX path replaces the keyboard button with a text field.- Translate keys:
"$DropPrompt_Confirm"(drop button default),"$DropPrompt_Cancel"(cancel button default),"$Keyboard_Desc_nx"(NX keyboard hint).
Other game-specific classes
BtnGreen— Embedssymbol76; greenLabelButtonskin with 4 stop-frames at frames 10/20/30/40 (up/over/down/disabled). Used as the confirm/cancel button skin.MaxButton— Embedssymbol30;BaseButtonskin for the Max button; same 4-stop-frame layout.MinButton— Embedssymbol40;BaseButtonskin for the Min button; same 4-stop-frame layout.DPAD_Console— Embedssymbol21;UIComponentsubclass representing the D-Pad directional icon with 2 frame states (frames 0 and 10).- Console button icon wrappers (pure
MovieClipembed stubs, no logic):btn_console_south(symbol89),btn_console_east(symbol90),btn_console_lt(symbol88),btn_console_rt(symbol91),btn_console_keyboard(symbol92),btn_console_dpad_updowneast(symbol87) — 6 asset-wrapper classes.
Notable logic
- Dynamic centering:
setMaxcomputes the total width of all visible controls (maxButton + gap + [console extras] + minButton + gap + textInput + gap + [dpad/increment] + [keyboard button]) and offsets the leftmost control by(bg.width - totalWidth) / 2, producing a centered row regardless of digit count. - Input validation flow: every non-destructive key press (
onKeyPressed) callsinvalidate(InvalidationType.DATA), which schedulesdraw()to re-apply thequantitysetter, clamping out-of-range typed values without interrupting mid-edit. - Enter key shortcut:
checkEnterKeyonKEY_UPsubmits the drop if the Enter/Return key is pressed, equivalent to clicking the drop button. setQuantityfocuses the field: after programmatically setting a quantity from the engine, the text field is focused and fully selected so the player can immediately type a replacement value.- Max=0 edge case: if
setMax(0)is called,quantityis forced to 0 and the layout is not recalculated (no controls shown at valid sizes), effectively making the drop impossible.