Quirk
06-03-2009, 04:05 AM
Ok, so I've been trying to learn AS3 and I've got a pretty good handle on being able to "read" it, but I'm having a hard time trying to wrap my head around "writing" it.
What I am trying to do is clicking on a movie clip and dragging it, but as I drag it I want it to advance frame by frame (for example, I drag the movie clip one pixel from the original place and the movie clip would advance one frame)
So, right now, I just have a movie clip on my stage and here is the actionscript for it...
grow_mc.addEventListener(MouseEvent.MOUSE_DOWN, dragGrow);
function dragGrow(event:MouseEvent):void
{
grow_mc.nextFrame();
grow_mc.startDrag();
grow_mc.removeEventListener(MouseEvent.MOUSE_DOWN, dragGrow);
grow_mc.addEventListener(MouseEvent.MOUSE_UP, dropGrow);
}
function dropGrow(event:MouseEvent):void
{
grow_mc.stopDrag();
grow_mc.addEventListener(MouseEvent.MOUSE_DOWN, dragGrow);
grow_mc.removeEventListener(MouseEvent.MOUSE_UP, dropGrow);
}
Of course, it only advances one frame on the MOUSE_DOWN, so to get it to advance again I would need to "drop" it and then click on it to start dragging.
Also, I wonder, should I just make a mathematical function since the tween is just scaling the object?
Just kind of stuck.. any insight would be much appreciated. Thanks in advance.
What I am trying to do is clicking on a movie clip and dragging it, but as I drag it I want it to advance frame by frame (for example, I drag the movie clip one pixel from the original place and the movie clip would advance one frame)
So, right now, I just have a movie clip on my stage and here is the actionscript for it...
grow_mc.addEventListener(MouseEvent.MOUSE_DOWN, dragGrow);
function dragGrow(event:MouseEvent):void
{
grow_mc.nextFrame();
grow_mc.startDrag();
grow_mc.removeEventListener(MouseEvent.MOUSE_DOWN, dragGrow);
grow_mc.addEventListener(MouseEvent.MOUSE_UP, dropGrow);
}
function dropGrow(event:MouseEvent):void
{
grow_mc.stopDrag();
grow_mc.addEventListener(MouseEvent.MOUSE_DOWN, dragGrow);
grow_mc.removeEventListener(MouseEvent.MOUSE_UP, dropGrow);
}
Of course, it only advances one frame on the MOUSE_DOWN, so to get it to advance again I would need to "drop" it and then click on it to start dragging.
Also, I wonder, should I just make a mathematical function since the tween is just scaling the object?
Just kind of stuck.. any insight would be much appreciated. Thanks in advance.