17 Replies Latest reply on Jan 23, 2007 7:03 AM by Peter Lorent

    360 turnaround help

    jbw!
      I'm trying my hardest to learn actionscript and OOP but I'm finding my maths and programming fundamentals is seriously letting me down with this. I understand how these 360 turnarounds are created I just can't work out how to code the mouse movement to make the movie clip jump frames in different directions. Can anyone point me in the right direction please? (no pun intended! )

      Also does anyone know of a decent programming book that discusses this type of programming so my brain can engage on this level?

      ta,
      jbw
        • 1. Re: 360 turnaround help
          Peter Lorent Level 2
          If you are doing a carousel, head over to www.gotoandlearn.com -> 3 tutorials
          Book: Foundation Actionscript Animation by Keith Peters. Highly recommended.
          • 2. Re: 360 turnaround help
            jbw! Level 1
            quote:

            Originally posted by: LuigiL
            If you are doing a carousel, head over to www.gotoandlearn.com -> 3 tutorials
            Book: Foundation Actionscript Animation by Keith Peters. Highly recommended.


            Thanks for the book suggestion - most appreciated.
            I'm not after the carousel, even though it'll be useful to go through. The type of effect I'm trying to do can be found on a wide range of product websites. They show a 360 view of the product that when the user clicks and drags it spins either left or right depending on the direction the mouse is moved. Example - highlight 'design dropdown' then click 'alienfx' link to see effect
            • 3. Re: 360 turnaround help
              Peter Lorent Level 2
              Basically, in an onEnterFrame you check where the mouse is using the _xmouse and/or _ymouse positions and based on that conditional call a function that performs a rotation of the object.
              • 4. 360 turnaround help
                jbw! Level 1
                So I've made some progress, please be kind - I'm learning and it's mostly pieces of code I've put together from various tutorials.
                Currently when I move the mouse left or right the movieclip 'box' plays either forwards or backwards but I need this to happen when the user has the mouse button pressed down and nothing I do seems to work.

                • 5. Re: 360 turnaround help
                  Peter Lorent Level 2
                  Then you need the events of the Mouse Class -> hit F1 in Flash and search for Mouse.
                  example:
                  var mouseListener:Object = new Object();
                  mouseListener.onMouseDown = MouseMove; //rename your function onMouseMove to MouseMove
                  Mouse.addListener(mouseListener);
                  • 6. Re: 360 turnaround help
                    jbw! Level 1
                    Thanks LuigiL but it seems if I change the name of function onMouseMove it stops working. I tried renaming it and using your suggested mouselistener code but no joy.
                    I imagine it's something to do with this.watch("xdir", mousedirection); and xdir but being a total novice I can't be sure.
                    • 7. Re: 360 turnaround help
                      Peter Lorent Level 2
                      Try the attached code.

                      • 8. Re: 360 turnaround help
                        jbw! Level 1
                        Cheers mate but that code lets me go forwards or backwards through the timeline dependant on whether I click the mouse on the left or right half of the stage. If I hold the mouse down it doesn't move frames as I drag left or right, which is what I'm after. I need it to see which way the mouse is moving then either step forward or backwards through the movieclip timeline.

                        That book you suggested arrived this morning. It's chuffing brilliant thank you.
                        • 9. Re: 360 turnaround help
                          Peter Lorent Level 2
                          The code is just example code.
                          Then you would use:
                          mouseListener.onMouseMove = MouseMove;
                          and instead of using Stage.width you can use any conditional there like my_clip._width/2
                          • 10. Re: 360 turnaround help
                            jbw! Level 1
                            I really appreciate your help LuigiL but I can't get it to function in the same way as the example I posted earlier. Maybe the way I'm going about this is all wrong.
                            If I use a conditional based on the left or right side of a mc by using 'my_clip._width/2' it doesn't function correctly because at a certain point when the mouse changes direction it will continue to spin in the original direction.
                            • 11. Re: 360 turnaround help
                              Peter Lorent Level 2
                              That would be logical if the clip is on either side of the middle of the stage since the code checks: _root._xmouse
                              but then again I don't know if you are using that code exactly.
                              Upload your fla somewhere and post a link so we can download the fla. It's a little too abstract now.
                              • 12. 360 turnaround help
                                jbw! Level 1
                                Most appreciated. You should find it at: http://uk.geocities.com/cwestbrook@btinternet.com/Move07.zip
                                Flash 8 fla. You should see the problem with the current code when you test movie.

                                I've been thinking about this and wondered if it's possible to create a sum that could equal the frame number (of the animation) dependant on where the mouse was when the user clicked and where it is when dragged? Does that make sense?
                                • 13. 360 turnaround help
                                  Peter Lorent Level 2
                                  Something like attached code? You can either click left or right to spin the box, or keep the mouse pressed and 'drag' to the left or right. And try setting the speed of the movie to 31 fps which makes it smoother.

                                  • 14. Re: 360 turnaround help
                                    jbw! Level 1
                                    Hey LuigiL, thanks for spending the time. It works well but isn't quite what I'm after. In the original example I gave, when the mouse is clicked and dragged left it plays the movieclip backwards but the moment you drag right (without releasing the mouse button) it plays forwards again, regardless of the position of the mouse.
                                    This code however, will continue to play the movieclip backwards until the mouse passes over the half way mark setout by the mousedirection function.
                                    • 15. Re: 360 turnaround help
                                      Peter Lorent Level 2
                                      Then use the old code in the new code.

                                      • 16. Re: 360 turnaround help
                                        jbw! Level 1
                                        Oh wow! I can't believe I overlooked that... it works, it chuffing well works! You're a star LuigiL. I can only offer you virtual beer as a thankyou. I really appreciate the amount of time you've spent helping me with this. Cheers, jbw


                                        • 17. Re: 360 turnaround help
                                          Peter Lorent Level 2
                                          (burp, sorry) You're welcome.