There are several ways to complete a quest. In the previous example, the player completes the quest by talking to the NPC or adding friends. We can complete a quest anywhere and dispatch a complete event to inform the monitoring quest daemon.
Another common method to complete a quest is to hand in an item that the NPC needs. A panel will pop up for the player to hand in some items. The panel is basically the same as the selling item panel that was discussed in the last chapter except that now we are giving a specific item to NPC instead of selling any items. Therefore, the only difference between this panel and the selling panel is that we need to check if the submit item is what NPC needs. The NPC's desired item type is stored in daemon manager as waitingItemType.
In the following code, players are required to submit a duck item to the NPC:
private function handinItem(e:MouseEvent):void { var itemList:Array = Myself.instance.itemList; var targetItem:ItemData = itemList...