trade.swf
The player-to-player trade (and deconstructor) window in Trove. Shows a pending-player list while waiting for a trade partner, then switches to a two-panel item exchange view where both players can offer items, lock in, and accept the trade. Also reused for the Deconstructor collect flow.
Document/main class: Trade (extends _kiwi.Core.UIComponent)
SWF-specific classes: 6 (plus 9 Trade_fla timeline symbols and several skin/asset wrappers)
Main class: Trade
Trade is the root document class. The constructor registers frame scripts for frames 0 and 10, immediately calls showPendingPlayers(), and in the Iggy path registers four ExternalInterface callbacks and hides itself on console until onTargetFrame() is reached. configUI() hides tradePanel.buttonLegend. onStageResized scales backBanner.height proportionally to the stage height.
Public methods
showPendingPlayers() : void— sets_mode = MODE_PLAYER_LIST, showsplayerListPanel, hidestradePanel, sets button legend to "Off".initTradeSession(p1Name, p2Name, p1Max, p2Max, isDeconstruct) : void— caches all parameters, sets_mode = MODE_TRADE, showstradePanel, hidesplayerListPanel, sets button legend to "On", callstradePanel.configCategories(...). WhenisDeconstructistrue, setsacceptButton.labelto"$Deconstructor_Collect"and on console setssouthButtonframe to "Collect".setTitlebar(text:String) : void— stores title and assigns it toheader.title.GainedFocus() : *— makestradePanel.buttonLegendvisible; on NX console callsPositioningButtonsto reposition the legend and adjustssouthButton.y = 75.LostFocus() : *— hidestradePanel.buttonLegend.
Key fields
playerListPanel : MovieClip— panel shown while searching for a trade partner: aPlayerListPanel(Embed symbol169) holding the list of players waiting at the post and the Trade button.tradePanel : TradePanel— the actual two-column item exchange panel.header : WindowHeader— title bar; updated viasetTitlebar.backBanner : MovieClip— background banner; height scaled proportionally on resize.closeButton : MovieClip— hidden on console; triggersTRADE.CLOSE_REQUESTon click._mode : int—MODE_PLAYER_LIST (1)orMODE_TRADE (2).SLOTS_PER_ROW : int = 6— sent to game viaTRADE.CONFIGUREDon console init._player1Name / _player2Name : String,_player1Max / _player2Max : Number,_isDeconstruct : Boolean— cached parameters for deferred console init.
Frame scripts / timeline
- Frame 0 (
frame1) —stop(). PC layout. - Frame 10 (
frame11) —stop(). Console layout: callstradePanel.gotoAndPlay("Console").
Runtime dependencies & integration
- Iggy callbacks registered:
showPendingPlayers,initTradeSession,setTitlebar,GainedFocus,LostFocus. - ExternalInterface calls out:
TRADE.CONFIGURED(withSLOTS_PER_ROW; console only),TRADE.CLOSE_REQUEST. PlayerListPanel(theplayerListPanelinstance): registersaddPendingPlayer(id, name)andremovePendingPlayer(id), plusmoveHighlightandclickTradeonly whenIsConsole(). Its Trade button sendsTRADE.SELECTED_PLAYER(id)for the selected row; removing the selected row disables the button.- translate keys:
"$Deconstructor_Collect"(used whenisDeconstructis true). IsConsole(),IsNX(),PositioningButtons()called in focus/init paths.setupTranslation()not called directly inTrade— delegated toTradePanel.
Class: TradePanel
Sub-component managing the two-sided item display and accept flow. Extends _kiwi.Core.UIComponent.
Responsibilities
Created as a named instance (tradePanel) on the Trade stage. In its constructor it creates two BagContainer instances (disableCollapse = true) for categories 0 and 1 and adds them to offerContainer1/offerContainer2. configUI() registers a SlotDragDropHelper drop callback and all per-panel Iggy callbacks.
Public methods
configCategories(p1Name, p2Name, p1Max, p2Max) : void— sets category label and capacity for eachBagContainer:p1Name/p1Maxgo to category 0 (the trade partner),p2Name/p2Maxto category 1 (the local player). In a player trade each side's capacity is 16.addOfferedItem(category, icon, slotId, qty, color, showQty, quality) : void— callsofferCategories[cat].addObject(...). EnablesacceptButtonif local accept state is 0 and resets the accept-pending background. Only category 1's (the local player's) items are drag-enabled — dragging an offered item out is how it goes back to the bags. The tooltip strings passed are the literals"name"and"description"; the real item tooltip comes from the engine through the slot's pointer events.removeOfferedItem(category, slotId) : void— callsofferCategories[cat].removeBySlotId(slotId). DisablesacceptButtonif both categories are empty.updateOfferedItem(category, slotId, qty, color) : void— delegates toBagContainer.updateBySlotId.slotIdFromIndex(index:int) : int— negative indices address category 1 (high bit masked off); non-negative address category 0.
Private methods
cancelAccept()— resets accept backgrounds, sets label to"$TradingPost_LockIn", re-enables button.indicateAccept(who, state)— trackslocalPlayerAcceptState(who == 1) andotherPlayerAcceptState(who == 0). When local is one ahead of remote, disables button with"$TradingPost_Waiting"label. Otherwise enables with"$TradingPost_LockIn"(state 0) or"$TradingPost_Accept"(state 1+), and advances consolesouthButtonframe.onDrop(x, y, icon, qty, slotId)— callsTRADE.DROP_ONTO_WINDOWand playsPlay_ui_window_drop_interactivesound. The drop point is not hit-tested: anything dropped anywhere on the window is forwarded.onAccept(e:MouseEvent)— callsTRADE.ACCEPT.showControllerTooltip(index) / hideControllerTooltip(index)— delegates to the appropriateBagContainertooltip method; negative index targets category 1 using high-bit masking.activateSlot(index) / deactivateSlot(index)— same sign-based routing toBagContainer.activateSlot/deactivateSlot.acceptButtonClick()— console path: dispatchesMouseEvent.CLICKonacceptButtonprogrammatically.
Key fields
offerCategories : Object (Array)— twoBagContainerinstances: index 0 is the trade partner (shown in the upperofferContainer1), index 1 is the local player (the lowerofferContainer2, y 328).acceptButton : LabelButton— lock-in/accept/collect/waiting button.offerContainer1 / offerContainer2 : MovieClip— visual containers for each BagContainer.acceptBg1 / acceptBg2 : MovieClip— semi-transparent "accepted" highlight; shown whenindicateAcceptfires.buttonLegend : MovieClip— console button overlay.localPlayerAcceptState / otherPlayerAcceptState : int— two-step acceptance state machine (0 = none, 1 = locked, 2 = accepted).
Iggy callbacks registered in TradePanel
configCategories, addOfferedItem, removeOfferedItem, updateOfferedItem, cancelAccept, indicateAccept, showControllerTooltip, hideControllerTooltip, getInventorySlotId, activateSlot, deactivateSlot, slotIdFromIndex, and (console only) acceptButtonClick.
ExternalInterface calls out from TradePanel
TRADE.DROP_ONTO_WINDOW, POST_SOUND_EVENT("Play_ui_window_drop_interactive"), TRADE.ACCEPT.
translate keys
"$TradingPost_LockIn", "$TradingPost_Waiting", "$TradingPost_Accept". setupTranslation() called in configUI.
Class: TradePlayerList
Embed symbol167; extends fl.controls.List. Overrides drawList() to fix CellRenderer text field width to the full component width (rather than the default available-width calculation). Used as the list control in playerListPanel.
Class: InventoryRow
Embed symbol61; extends com.kiwi.Core.KiwiComponent. Trivial asset-wrapper — no custom logic. Used as the item-row display in the trade grid or inventory panel.
Trade_fla timeline symbols
Trade_fla/bannerTop_2— Embed symbol179; top decorative banner; 15-frame animation, stops at frame 15.Trade_fla/bannerBottom_5— Embed symbol182; bottom decorative banner; same 15-frame structure.Trade_fla/buttonLegend_41— Embed symbol113; console button legend strip; exposestradeButtonLegend,switchButtonLegend,closeButtonLegend,southButton; two stops (frame 0 PC / frame 10 console).Trade_fla/categoryCapacity_50— Embed symbol72; capacity indicator withcountTextFieldandmaxCapacityTextField; two stops.Trade_fla/slotFrame_53— Embed symbol35; four-state slot border clip (frames 1–4).Trade_fla/equipped_56— Embed symbol42; equipped indicator; frame 1 stops, frame 61 loops back to "Pulse".Trade_fla/equiped_54— Embed symbol37; equipped tween clip withbmpTweenchild; same loop-back pattern.Trade_fla/qualityPips_62— Embed symbol59; quality pip display; stops on frame 1.Trade_fla/button_A_42— Embed symbol106; console A-button prompt; stops on frame 1.
Asset / skin wrappers (not individually documented)
Scroll bar skins (9): ScrollArrowDown_*, ScrollArrowUp_*, ScrollThumb_*, ScrollTrack_skin, ScrollBar_thumbIcon.
List cell skins (8): CellRenderer_upSkin, CellRenderer_downSkin, CellRenderer_overSkin, CellRenderer_disabledSkin, CellRenderer_selectedUpSkin, CellRenderer_selectedDownSkin, CellRenderer_selectedOverSkin, CellRenderer_selectedDisabledSkin.
Other skins: List_skin, focusRectSkin, CloseIcon, CloseIconPressed.
Rarity frame wrappers (16): rarity_frame_common_png through rarity_frame_stellar and _over variants (common, uncommon, rare, epic, legendary, relic, shadow, radiant1, resplendent, stellar, mystic, crystal, normal, mystic_over, crystal_over, normal_over).
Notable logic
- Slot index sign encoding: Negative slot indices in
showControllerTooltip,hideControllerTooltip,activateSlot,deactivateSlot, andslotIdFromIndexall decode the category-1 index by masking off the sign bit (param & ~(1 << 31)). This allows a single integer parameter to encode both the category (sign) and the slot index. - Two-step accept state machine:
indicateAcceptimplements a two-stage commit — lock-in first, then accept — by comparinglocalPlayerAcceptStateandotherPlayerAcceptState. The button label transitions LockIn → Waiting → Accept to reflect the handshake. - Deconstructor reuse:
initTradeSessionwithisDeconstruct = truechanges only the accept button label and console button frame; the full trade UI is otherwise unchanged. - NX button positioning:
GainedFocuscalls the globalPositioningButtons()(Iggy helper) to align the legend with the panel boundary, then hard-codessouthButton.y = 75for NX layout. - Console deferred init: On console,
Tradeis constructed invisible and defers all panel configuration untilonEnterFrameconfirmsonTargetFrame(); at that point it callsTRADE.CONFIGURED(SLOTS_PER_ROW)before making itself visible.