Hi all,
Using flash.display.Sprite object, I am creating an application where it
should look like a closed shape with n angles, n is represented as small
circle(s), Node(s). The node object is drag-droppable. At drag event of each
node the connected lines (predecessor and successor) shuld also adjust in
such a manner to make the figure complete one.
I have tried two algorithms as under:
1.When node is dragged (till dropped), all edges are redrawn on basis of
current reference to successor's reference like circular queue.
2.When node is dragged, only edges connected with predecessor and successor
are redrawn on new x, y points.
Here is a code snippet for 1st algorithm
private function onMouseMove(event:MouseEvent):void
{
drawLine(event.target.x, event.target.y,
predecessorNode.x, predecessorNode.y);
drawLine(event.target.x, event.target.y,
successorNode.x, successorNode.y);
}
private function drawLine(x1:Number, y1:Number, x2:Number, y2:Number):void
{
edge.graphics.clear();
edge.graphics.lineStyle(1, 0x0000ff);
edge.graphics.moveTo(x1, y1);
edge.graphics.lineTo(x2, y2);
}
Here is a code snippet for 2nd algorithm
public function drawAllLines(node:Node):void
{
var currentNode:Node = node;
while((currentNode.x == node.x) && (currentNode.y == node.y))
{
currentNode.edge.graphics.clear();
currentNode.edge.graphics.lineStyle(1, 0x0000ff);
currentNode.edge.graphics.moveTo(currentNode.x, currentNode.y);
currentNode.edge.graphics.lineTo(currentNode.successorNode.x,
currentNode.successorNode.y);
currentNode = currentNode.successorNode;
}
}
The strange behavior is that the connected line (edge) is divided in exact 2
equal part when mouse movement starts.
Also, the co-ordinates are not matching so as to make the shape
closed-complete one. Edges do not connect to nodes.
Any useful guidance/suggestion from anyone?
Regards,
Harit Kothari
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex
India Community" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---