Commits

Michal Gron committed c4c8fc9

action list - skeleton

Comments (0)

Files changed (4)

action-list/src/Action.as

+package
+{
+	public class Action
+	{
+		private var _ownerList : ActionList;
+
+		public var prev : Action;
+		public var next : Action;
+
+		public function get isFinished() : Boolean
+		{
+			return false;
+		}
+
+		public function get isBlocking() : Boolean
+		{
+			return false;
+		}
+
+		public function get lanes() : uint
+		{
+			return 0;
+		}
+
+		public function get elapsed() : Number
+		{
+
+		}
+
+		public function get duration() : Number
+		{
+
+		}
+
+		public function Action()
+		{
+		}
+
+		public function update(delta : Number) : void
+		{
+
+		}
+
+		public function onStart() : void
+		{
+
+		}
+
+		public function onEnd() : void
+		{
+
+		}
+	}
+}

action-list/src/ActionList.as

+package
+{
+	public class ActionList
+	{
+		private var _duration : Number;
+		private var _timeElapsed : Number;
+		private var _percentDone : Number;
+		private var _blocking : Boolean;
+		private var _lanes : uint;
+		private var _actions : Vector.<Action>; // can be a vector or linked list
+
+		public var head : Action;
+		public var tail : Action;
+
+		private var _size : int;
+
+		public function get size() : int
+		{
+			return _size;
+		}
+
+		public function ActionList()
+		{
+			head = new Action();
+			tail = new Action();
+
+			head.next = tail;
+			tail.prev = head;
+		}
+
+		public function get isEmpty() : Boolean
+		{
+
+		}
+
+		public function get timeLeft() : Number
+		{
+
+		}
+
+		public function get isBlocking() : Boolean
+		{
+
+		}
+
+		public function update(delta : Number) : void
+		{
+
+		}
+
+		public function pushFront(action : Action) : void
+		{
+			head.next.prev = action;
+			action.next = head.next;
+
+			head.next = action
+			action.prev = head;
+
+			// node.list = this;
+
+			_size++;
+
+		}
+
+		public function pushBack(action : Action) : void
+		{
+			tail.prev.next = action;
+			action.prev = tail.prev;
+
+			tail.prev = action;
+			action.next = tail;
+
+			// node.list = this;
+
+			_size++;
+		}
+
+		public function insertBefore(action : Action) : void
+		{
+
+		}
+
+		public function insertAfter(action : Action) : void
+		{
+
+		}
+
+		public function remove(action : Action) : Action
+		{
+			action.prev.next = action.next;
+			action.next.prev = action.prev;
+
+			action.next = null;
+			action.prev = null;
+
+			// node.list  = null;
+			_size--;
+		}
+
+		public function begin() : Action
+		{
+		}
+
+		public function end() : Action
+		{
+
+		}
+
+		public function getIterator() : Iterator
+		{
+			return new Iterator(this);
+		}
+	}
+}

action-list/src/ActionListApp.as

+package {
+
+import flash.display.Sprite;
+import flash.text.TextField;
+
+public class ActionListApp extends Sprite {
+    public function ActionListApp() {
+        var textField:TextField = new TextField();
+        textField.text = "Hello, World";
+        addChild(textField);
+    }
+}
+}

action-list/src/Iterator.as

+package
+{
+	public class Iterator
+	{
+		private var _node : Action;
+		private var _list : ActionList;
+
+		public function Iterator(list : ActionList)
+		{
+			_list = list;
+			_node = _list.head.next;
+		}
+
+		public function hasNext() : Boolean
+		{
+			return _node.next != _list.tail;
+		}
+
+		public function hasPrev() : Boolean
+		{
+			return _node.prev != _list.head;
+		}
+
+		public function first() : Iterator
+		{
+			_node = _list.head.next;
+			return this;
+		}
+
+		public function last() : Iterator
+		{
+			_node = _list.tail.prev;
+			return this;
+		}
+
+		public function next() : void
+		{
+			_node = _node.next;
+		}
+
+		public function prev() : void
+		{
+			_node = _node.prev;
+		}
+
+		public function data() : *
+		{
+			if(_node != _list.head && _node != _list.tail) {
+				return _node;
+			}
+
+			return null;
+		}
+
+//		public function remove() : void
+//		{
+//			var next : Action = _node.next;
+//			_list.remove(_node);
+//			_node = next;
+//		}
+
+//		public function clone() : Iterator
+//		{
+//			var copy : Iterator = new Iterator(_list);
+//			copy.node = _node;
+//
+//			return copy;
+//		}
+
+		public function copy(target : Iterator) : Iterator
+		{
+			target.list = _list;
+			target.node = _node;
+
+			return target;
+		}
+	}
+}