Mouse click and drag through turntable animation
Hi all,
First - thanks for taking the time to look through and possibly helping me with this question.
I'm just getting to grips with flash cc actionscript 3.0 - so I apologise in advance to my not so technical jargon.
In the past I have used actionscript 1.0 to create an interactive html file that contains a turntable animation of a 3D model. Users can mouse click and drag to the left or right to 'spin' the model around - however what they are really doing is scrubing through the timeline which contained 360 images of it from 360 degrees. Similar ideas can be found here: Interactive Thyroidectomy
Now annoying I can't use the old code any more as I'm working in the latest flash cc actionscript 3.0
So how do I do the same thing but in actionscript 3.0?
So I've worked this bit out so far
On my main stage I have two layers - actions layer and another layer with my movie clip (movieclip_mc)
In the actions layer so far:
movieclip_mc.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
movieclip_mc.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
function onMouseDown(event:MouseEvent😞void
{
movieclip_mc.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
//I should put something in here about mouseX - but no idea what
}
function onMouseUp(event:MouseEvent😞void
{
movieclip_mc.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
}
function onMouseMove(event:MouseEvent😞void
{
//I have to put something in about total frames - width of movieclip_mc etc but I'm not sure how
// this is what someone else did on another forum - but I'm not sure what it means:
var delta:int = backgroundClip.mouseX - clickedMouseX;
var wantedFrame:uint = (clickedFrame + delta * clip.totalFrames / backgroundClip.width) % clip.totalFrames;
while (wantedFrame < 1)
{
wantedFrame += clip.totalFrames;
}
clip.gotoAndStop(wantedFrame);
}
Also I think i need something in the beginning like.....:
import flash.events.MouseEvent;
import flash.display.MovieClip;
import flash.display.Sprite;
var clickedMouseX:int;
var clickedFrame:uint;
var backgroundClip:Sprite = getChildByName("background") as Sprite;
var clip:MovieClip = getChildByName("animation") as MovieClip;
clip.stop();
clip.mouseEnabled = false;
.....but I'm a bit confused about what all of it means
So I understand the principle but no idea how to actually make it work - Could anyone help explain it to me or help with the code?
Thanks so much to anyone who can offer some help
Catherine