1 package net.systemeD.halcyon.connection.actions {
3 import net.systemeD.halcyon.connection.*;
4 import net.systemeD.halcyon.Globals;
6 public class AddNodeToWayAction extends UndoableEntityAction {
8 private var nodeList:Array;
11 public function AddNodeToWayAction(way:Way, node:Node, nodeList:Array, index:int) {
12 super(way, "Add node "+node.id+" to");
14 this.nodeList = nodeList;
18 public override function doAction():uint {
19 var way:Way = entity as Way;
21 index = nodeList.length;
23 nodeList.splice(index, 0, node);
26 way.dispatchEvent(new WayNodeEvent(Connection.WAY_NODE_ADDED, node, way, index));
31 public override function undoAction():uint {
32 var way:Way = entity as Way;
33 var removed:Array=nodeList.splice(index, 1);
34 if (nodeList.indexOf(removed[0])==-1) { removed[0].removeParent(way); }
36 way.dispatchEvent(new WayNodeEvent(Connection.WAY_NODE_REMOVED, removed[0], way, index));