Tuesday, 10 September 2013

AS3 Calling Function containing startDrag from another function

AS3 Calling Function containing startDrag from another function

I got 2 objects and a number of hitbox "nodes", if you release on the node
it hides the object and puts up a dummy object. when you click the object
it brings back the old object and hides the dummy .
what im having trouble with is clicking the dummy object and starting drag
on the original object from the dummy object.the objects are not dragging.
// code located on dummy object
hideb.addEventListener(MouseEvent.MOUSE_DOWN, hideEventab);
function hideEventab(event:MouseEvent):void
{
this.visible = false;
// this statment finds out if its object 1 or object 2
if (currentFrame == 1 )
{
MovieClip(parent.parent).VoltageAs.redBtn1.visible = true;
MovieClip(parent.parent).VoltageAs.dragcurrentClip7 =
MovieClip(parent.parent).VoltageAs.redBtn1;
MovieClip(parent.parent).VoltageAs.item_onMouseUp3(null);
}
else if (currentFrame == 2 )
{
MovieClip(parent.parent).VoltageAs.blkbtn1.visible = true;
MovieClip(parent.parent).VoltageAs.dragcurrentClip7 =
MovieClip(parent.parent).VoltageAs.blkbtn1;
MovieClip(parent.parent).VoltageAs.item_onMouseUp3(null);
}
}
and next
// this function is supposed to be called when you click the dummy object.
function item_onMouseDown3(event:MouseEvent):void
{
dragcurrentClip7.y = mouseY;
dragcurrentClip7.x = mouseX;
startX7 = dragcurrentClip7.x;
startY7 = dragcurrentClip7.y;
dragcurrentClip7.startDrag();
trace(dragcurrentClip7.name);
stage.addEventListener(MouseEvent.MOUSE_UP, item_onMouseUp3);
if (dragcurrentClip7 == redBtn1 || dragcurrentClip7 == blkbtn1)
{
dragcurrentClip7.nextFrame();
}
}

No comments:

Post a Comment