-
Need advice: Moving forward/backward thru sequence of images
I'm putting together a product viewer, which will rotate a product for viewing depending on where the user drags their mouse - similar to Quicktime VR, but instead of panning around a scene, the viewer will remain fixed and the product will be rotating as if on a turntable.
The sequence is 72 frames - one frame per 5 degrees of rotation. The animator can provide either a movie or a sequence of still frames. I'm trying to work out the best way to animate it.
My first inclination is to create a 72 frame movie clip with one image per frame, and step through forwards or backwards one frame at a time at different rates depending on where the mouse is positioned. I don't think I can play a video forward and backward from just any old point (e.g if the user stops while looking at the back of the object and then starts spinning it the other way). Seems much more straightforward to be able to just step sequentially through the frames, in either direction, from any point (wrapping around when it gets to the end).
Does that sound like a good approach?
- Bob
-
I'm pretty sure there is a way to pause the movieclip, maybe you can to a position check for the mouse, so if the x and y position of the mouse is the same as the last frame, then pause the movieclip. If it starts moving again, then start playing. I'm not too sure on the actionscript for it, maybe an IF statement woudl be the best way to go?
I'm sure a more adept actionscripter will tell you an easier way of doing it though
EDIT: I just read my post through, and realised that it wouldnt help.
Maybe you should allow the user to pause the movieclip with a mouse click? Then the user can pause it whenever he/she desires. I think I thought about thsi one a bit too much xD
-
I'm not just talking about pause and play - I want the speed to vary depending on the position of the mouse, and it has to "play" backwards when the mouse is over the left half of the image.
What I'm thinking is onEnterFrame I check the mouse position, and translate that into gotoAndStop for the movie clip. Not sure how to approach the varying speed though. I suppose I could do half speed by telling it to set a var, and if the var is set then advance the movie clip and clear the var, so on the next frame there would be no var, the movieclip wouldn't advance, and it would set the var again.
I just bet somebody's already solved this...
-Bob
-
here's one approach (this works for me; obviously you'll have to replace the various object references, but hopefully you get the idea) - and a disclaimer: i doubt this is the most efficient method, but it works
PHP Code:
var timer = new Timer(0);
function go(direction,interval) {
timer.stop();
timer = new Timer(interval);
timer.start();
var func = direction ? function(e){
animation.prevFrame()
} : function(e){
animation.nextFrame()
};
timer.addEventListener("timer",func);
}
function start(e) {
var num = holder.width/2 - holder.mouseX;
var bool = num > 0;
var abs = holder.width/2 - Math.abs(num);
if (abs > 0) {
go(bool,abs);
}
}
container.addEventListener("mouseMove",start);
where "animation" is the clip with multiple frames (which should have a stop action on it), and "container" is the thing that holds it and is recieving the mouse event.
-
You could use TweenLite to tween the frames around but you'll run into problems 'looping' it, you could also hook the current frame directly to mouse position:
PHP Code:
stage.addEventListener(MouseEvent.MOUSE_MOVE, function(e:MouseEvent):void{
var mousePercentage:Number = e.stageX / stage.stageWidth;
container.gotoAndStop(int(mousePercentage * container.totalFrames));
});
-
Thanks moagrius, I think that'll get me on the right road!
Neznein, hooking frame to mouse position won't work, I think. We want it to "play" (i.e. rotate freely) at different speeds depending on where the mouse is positioned.
-
Forgive me I am slightly noob so I don't know if what I am suggesting is possible but just thought I would throw it out case if it is it would give you a direction to look. But here goes:
Is it not possible to set the FrameRate of a movie at run time? if so why not increase the Framerate while at certain mouse positons to speed up animation (which in the cheapest most likely most inefficient way could be controlled with hotspots or invisible buttons but still able to produce the effect. But I am sure Mouse tracking function would be better.)
Anyway just any idea if it is possible then maybe it gives you something to think about?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|