Skip to content

Commit

Permalink
Significant reworking, many features disabled while restructing archi…
Browse files Browse the repository at this point in the history
…tecture.
  • Loading branch information
secoif committed Feb 15, 2010
1 parent 63fee48 commit 6c7cb14
Show file tree
Hide file tree
Showing 32 changed files with 1,437 additions and 1,663 deletions.
Binary file added libs/as3-signals.swc
Binary file not shown.
13 changes: 12 additions & 1 deletion src/com/comtaste/pantaste/behaviours/BehaviourBase.as
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -117,13 +117,15 @@ package com.comtaste.pantaste.behaviours {
} }


public function removeModifier(modifier:IBehaviourModifier):void { public function removeModifier(modifier:IBehaviourModifier):void {
modifier.behaviour = null;
var index:uint = modifiers.indexOf(modifier); var index:uint = modifiers.indexOf(modifier);


if (index < 0) { if (index < 0) {
throw new Error("Modifier not found in collection: " + modifier); throw new Error("Modifier not found in collection: " + modifier);
} }
modifiers.splice(index, 1); modifiers.splice(index, 1);
modifier.enabled = false;
modifier.behaviour = null;
} }


//---------------------------------------------------------- //----------------------------------------------------------
Expand All @@ -137,18 +139,27 @@ package com.comtaste.pantaste.behaviours {
} }


protected function start():void { protected function start():void {
if (modifiers.length == 0) {
return;
}
for each (var modifier:IBehaviourModifier in modifiers) { for each (var modifier:IBehaviourModifier in modifiers) {
modifier.start(); modifier.start();
} }
} }


protected function step():void { protected function step():void {
if (modifiers.length == 0) {
return;
}
for each (var modifier:IBehaviourModifier in modifiers) { for each (var modifier:IBehaviourModifier in modifiers) {
modifier.step(); modifier.step();
} }
} }


protected function stop():void { protected function stop():void {
if (modifiers.length == 0) {
return;
}
for each (var modifier:IBehaviourModifier in modifiers) { for each (var modifier:IBehaviourModifier in modifiers) {
modifier.stop(); modifier.stop();
} }
Expand Down
75 changes: 58 additions & 17 deletions src/com/comtaste/pantaste/behaviours/MoveBehaviour.as
Original file line number Original file line Diff line number Diff line change
@@ -1,15 +1,18 @@
package com.comtaste.pantaste.behaviours { package com.comtaste.pantaste.behaviours {
import com.comtaste.pantaste.common.DashConstants; import com.comtaste.pantaste.common.DashConstants;
import com.comtaste.pantaste.components.DashProxy; import com.comtaste.pantaste.components.DashProxy;

import flash.display.DisplayObject; import flash.display.DisplayObject;
import flash.events.Event; import flash.events.Event;
import flash.events.IEventDispatcher; import flash.events.IEventDispatcher;
import flash.events.MouseEvent; import flash.events.MouseEvent;
import flash.geom.Point; import flash.geom.Point;

import mx.core.FlexGlobals; import mx.core.FlexGlobals;
import mx.core.IVisualElement; import mx.core.IVisualElement;
import mx.core.UIComponent; import mx.core.UIComponent;
import mx.events.FlexEvent; import mx.events.FlexEvent;
import mx.logging.LogLogger;




public class MoveBehaviour extends TransformBehaviourBase { public class MoveBehaviour extends TransformBehaviourBase {
Expand Down Expand Up @@ -45,13 +48,14 @@ package com.comtaste.pantaste.behaviours {
// isMoving // isMoving
//-------------------------------------- //--------------------------------------


private var _isMoving:Boolean = false; private static var _isMoving:Boolean = false;


private function get isMoving():Boolean { public function get isMoving():Boolean {
return _isMoving; return _isMoving;
} }


private function set isMoving(value:Boolean):void { public function set isMoving(value:Boolean):void {
trace("isMoving = " + value);
_isMoving = value; _isMoving = value;


if (_isMoving) { if (_isMoving) {
Expand Down Expand Up @@ -86,12 +90,28 @@ package com.comtaste.pantaste.behaviours {
//---------------------------------------------------------- //----------------------------------------------------------


override protected function initialize():void { override protected function initialize():void {
if (target.stage) {
setup();
} else {
target.addEventListener(Event.ADDED_TO_STAGE, function(event:Event):void {
target.removeEventListener(Event.ADDED_TO_STAGE, arguments.callee);
setup();
});
}
super.initialize();
}

private function setup():void {
cursor = DashConstants.moveCursor; cursor = DashConstants.moveCursor;
offset = new Point(-10, -5);
super.dispatcher.addEventListener(triggerEvent, onMoveTriggered); super.dispatcher.addEventListener(triggerEvent, onMoveTriggered);
super.dispatcher.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver); //super.dispatcher.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
super.dispatcher.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut); super.dispatcher.addEventListener(MouseEvent.ROLL_OVER, onMouseOver);
//super.dispatcher.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
super.dispatcher.addEventListener(MouseEvent.ROLL_OUT, onMouseOut);
// target.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
target.addEventListener(MouseEvent.ROLL_OUT, onMouseOut);


super.initialize();
} }


//---------------------------------------------------------- //----------------------------------------------------------
Expand All @@ -107,10 +127,20 @@ package com.comtaste.pantaste.behaviours {
} }


private function onMouseMove(event:MouseEvent):void { private function onMouseMove(event:MouseEvent):void {
if (!enabled) {
return;
}
if (isMoving) {
if (!event.buttonDown) {
//onMouseUp(event);
}
step();
return;
}
if (preparingToDrag) { if (preparingToDrag) {
newPosition.x = event.stageX; newPosition.x = event.stageX;
newPosition.y = event.stageY; newPosition.y = event.stageY;
// var transformedOriginalPosition:Point = UIComponent(moveTarget.parentSelectable).localToGlobal(originalPosition)
var differenceX:Number = Math.abs(newPosition.x - originalMousePosition.x); var differenceX:Number = Math.abs(newPosition.x - originalMousePosition.x);
var differenceY:Number = Math.abs(newPosition.y - originalMousePosition.y); var differenceY:Number = Math.abs(newPosition.y - originalMousePosition.y);
var distance:Number = var distance:Number =
Expand All @@ -121,13 +151,13 @@ package com.comtaste.pantaste.behaviours {


} }
} }

step(); step();
trace('step');
} }


private function onMouseOut(event:MouseEvent):void { private function onMouseOut(event:MouseEvent):void {
if (event.currentTarget != dispatcher) { if (event.currentTarget != target || event.currentTarget != dispatcher) {
return; return;
} }


Expand All @@ -137,10 +167,14 @@ package com.comtaste.pantaste.behaviours {
} }


private function onMouseOver(event:MouseEvent):void { private function onMouseOver(event:MouseEvent):void {
if (event.currentTarget != dispatcher) { if (event.currentTarget != dispatcher || event.target != target) {
return; return;
} }
showCursor(); showCursor();
this.proxy.invalidateSnapshot();
this.proxy.createSnapshot();
this.proxy.scaleX = target.scaleX;
this.proxy.scaleY = target.scaleY;
} }


private function onMouseUp(event:MouseEvent):void { private function onMouseUp(event:MouseEvent):void {
Expand All @@ -149,6 +183,7 @@ package com.comtaste.pantaste.behaviours {


if (preparingToDrag) { if (preparingToDrag) {
preparingToDrag = false; preparingToDrag = false;
isMoving = false;
return; return;
} }
stopMoving(); stopMoving();
Expand All @@ -166,11 +201,14 @@ package com.comtaste.pantaste.behaviours {
triggeringEvent = event; triggeringEvent = event;


startMoving(); startMoving();

event.stopPropagation();
} }


private function startDragging():void { private function startDragging():void {
proxy.mode = DashProxy.MODE_SNAPSHOT;

start(); start();
isMoving = true;
if (proxy.initialized) { if (proxy.initialized) {
proxy.startDrag(); proxy.startDrag();
} else { } else {
Expand All @@ -182,6 +220,7 @@ package com.comtaste.pantaste.behaviours {
preparingToDrag = false; preparingToDrag = false;





proxyLayer.addElementAt(proxy, proxyLayer.numElements); proxyLayer.addElementAt(proxy, proxyLayer.numElements);
proxy.depth = target.depth + 1; proxy.depth = target.depth + 1;


Expand All @@ -190,14 +229,13 @@ package com.comtaste.pantaste.behaviours {
private function startMoving():void { private function startMoving():void {




isMoving = true;
proxy.mode = DashProxy.MODE_SNAPSHOT;
//proxy.depth = target.depth + 1;

var triggerPosition:Point = new Point(triggeringEvent.stageX, triggeringEvent.stageY); var triggerPosition:Point = new Point(triggeringEvent.stageX, triggeringEvent.stageY);
var targetPosition:Point = DisplayObject(proxyLayer).globalToLocal(triggerPosition); var targetPosition:Point = toCoordinateSpace(triggerPosition.x, triggerPosition.y, DisplayObject(proxyLayer));

proxy.x = target.x; proxy.x = target.x;
proxy.y = target.y; proxy.y = target.y;
proxy.scaleX = target.scaleX;
proxy.scaleY = target.scaleY;


originalPosition = new Point(target.x, target.y); originalPosition = new Point(target.x, target.y);
originalMousePosition = new Point(triggeringEvent.stageX, triggeringEvent.stageY); originalMousePosition = new Point(triggeringEvent.stageX, triggeringEvent.stageY);
Expand All @@ -222,6 +260,9 @@ package com.comtaste.pantaste.behaviours {
var position:Point = proxy.localToGlobal(new Point(proxy.x, proxy.y)); var position:Point = proxy.localToGlobal(new Point(proxy.x, proxy.y));


var newPosition:Point = target.globalToLocal(position); var newPosition:Point = target.globalToLocal(position);



proxy.x = 0; proxy.x = 0;
proxy.y = 0; proxy.y = 0;
originalPosition = new Point(); originalPosition = new Point();
Expand Down
Loading

0 comments on commit 6c7cb14

Please sign in to comment.