32 Replies Latest reply on Jan 5, 2009 7:09 AM by kglad

    scrolling with mouse movement code

    lou_bra Level 1
      Hello

      I have this code I used once to give a mouse movement effect to an animation through stage (using stage width as parameter) and it was working perfectly.

      Now I have to use this same illustration but flowing along a MC’s width, not all the stage, or it should define a specified width, different than the stage’s one.

      I trying using a mask over the old mc covering and showing only 747px width I want it to show, but o course it does not work properly, not showing the entire illustration.

      The mc I want to contain the illustration has 747px and the instance name “illustra”.

      In the frame now I have this:

      moveI = setInterval(moveF, 40);
      function moveF() {
      targetX = (1-mc1._width/Stage.width)*_xmouse;
      mc1._x = .5*(mc1._x+targetX);
      updateAfterEvent();
      }

      Thanks a lot any help!!!



        • 1. Re: scrolling with mouse movement code
          kglad Adobe Community Professional & MVP
          use an if-statement is you only want mc1 to ease into _xmouse when _xmouse is between certain limits.
          • 2. Re: scrolling with mouse movement code
            lou_bra Level 1
            thanks a lot kglad

            and sorry i'm not programmer. i'm just trying to give a nice effect to my web site but i dont know how to set "if" statements.

            "mc1" now must scroll only between 747px width, and i wish i could change the code to do it without creating a new mc (with a new width/code applyed to it) is that possible?

            if is not too much work, how to give that code this "if" or whatever if u think, in case is not necessary to create a new mc to have the mc1 inside. (?)

            thanks again

            • 3. Re: scrolling with mouse movement code
              kglad Adobe Community Professional & MVP
              :

              moveI = setInterval(moveF, 40);
              function moveF() {
              if(_xmouse<747){
              targetX = (1-mc1._width/Stage.width)*_xmouse;
              }
              mc1._x = .5*(mc1._x+targetX);
              updateAfterEvent();
              }
              • 4. Re: scrolling with mouse movement code
                lou_bra Level 1
                hey, thanks

                first i tryed using this code, NOT inserting the mc1 inside a new one.. then what happens is that maybe it really is scrolling 747 px but not at the correct position (what a new mc could define..) and also, was not showing all the image, that actully have 1852.2px width.

                then i tryed creating this new mc to define a correct position/limits of scrolling (instance name "mousem") and i inserted that mc1 inside, keeping this new code u gave me, in the frame where it is located and still not working. the mc1 does not respect the limits of the mc "mousem" and still scrolling along all the stage. registration point in both mcs are left/center.

                i really dont understand. it should have another code in the frame where "mousem" is located to work?

                thanks a lot for your time
                • 5. Re: scrolling with mouse movement code
                  kglad Adobe Community Professional & MVP
                  what exactly are you trying to do?
                  • 6. Re: scrolling with mouse movement code
                    lou_bra Level 1
                    ok,

                    I have a stage with 1024 width

                    there is a illustration (mc1) which sizes 1852.2px width and it should scroll horizontally within 747 px.

                    the correct position for scrolling with mouse movement is from de extreme right of the stage where it ends until 747px to the left side. so I still can have space in the stage (extreme right) for other elements.

                    what i dont want is the mc1 to scroll along the 1024 px of the stage, but i want the code to conserve its function of showing the entire illustration when mouse is in movement.

                    mc1 should flow along only in-between a limited space (747px), but it should scroll of course all the mc1 length (1852.2px) without using the entire stage.

                    now, i dont know if:

                    1. we should create a new mc to control the limited space of scrolling along

                    or

                    if in the actual code we can specify "run from the left until the right respecting the limit width 747px, but keep showing all the scrollable image length"

                    that is it.

                    thank you
                    • 7. Re: scrolling with mouse movement code
                      kglad Adobe Community Professional & MVP
                      mc1 is 1852.2 px wide and you want it to be displayed in its entirety on a stage that's 1024 in width? of course that makes no sense.

                      so, what do you mean by, "i want the code to conserve its function of showing the entire illustration"? what illustration?
                      • 8. Re: scrolling with mouse movement code
                        lou_bra Level 1
                        that makes sense.

                        why am i using mouse movement? to show something big in a smaller space. i'm sure this is correct to you.

                        i have this code working in my actual web site. mc1 has 1852px, and the old stage is even smaller than 1024 and i have my mouse movement working to show all the illustration.

                        code was perfect.

                        the only thing different now is that i want it to flow in limited space as i explained, not along all the stage.

                        clear?
                        • 9. Re: scrolling with mouse movement code
                          lou_bra Level 1
                          responding the second question

                          mc1 = illustration (the illustration (a graphic image) itself who runs along the stage containeid in a mc called mc1)
                          • 10. Re: scrolling with mouse movement code
                            kglad Adobe Community Professional & MVP
                            moveI = setInterval(moveF, 40);
                            function moveF() {

                            targetX = (747/Stage.width-mc1._width/Stage.width)*_xmouse;

                            mc1._x = .5*(mc1._x+targetX);
                            updateAfterEvent();
                            }
                            • 11. Re: scrolling with mouse movement code
                              lou_bra Level 1
                              i tried this code applied to the frame which contains mc1, but apparently nothing changes. mc1 stills running along all the stage.

                              when I insert mc1 inside a new mc (747px width) it runs badly flowing only 20 or 25% of the mc1.

                              what could be the problem? thanks
                              • 12. Re: scrolling with mouse movement code
                                kglad Adobe Community Professional & MVP
                                replace the code that caused mc1 to scroll (and that you posted here) with the code i gave.
                                • 13. Re: scrolling with mouse movement code
                                  lou_bra Level 1
                                  i did that before. now i did again, I erased the code from the frame and pasted yours. really strange but it stills doing the same, flowing along the stage
                                  • 14. Re: scrolling with mouse movement code
                                    kglad Adobe Community Professional & MVP
                                    that would only be possible if your stage were 747 px wide or you made a mistake.
                                    • 15. Re: scrolling with mouse movement code
                                      lou_bra Level 1
                                      hello there..

                                      no mistake... its a very simple copy/past, and stage has definatelly 1024px. instance name is ok, actully is the same mc1 i'm using now to do this test.

                                      is possible to me to send u the fla?

                                      or if u want me to try something else...

                                      i tried now placing a mask over the mc's frame but it cuts a little bit the mc1's image

                                      i tried placing the mc1 inside a new mc, and it stills not respecting the limits.. unabeliaveble...

                                      tell if you want me to send

                                      thanks a lot
                                      • 16. Re: scrolling with mouse movement code
                                        kglad Adobe Community Professional & MVP
                                        i rarely download and correct files unless i'm hired.
                                        • 17. Re: scrolling with mouse movement code
                                          lou_bra Level 1
                                          ok, no problem, I understand.

                                          i truly trust and respect your work here. it's probably some mistake i did and I cant see, or size of mc1 (1800px) was not specified in px in the code, should it be in cs3 (?) dont know, but no problem. I kept old code and changed my animation.

                                          just one last question:

                                          i need to apply a similar action to serial buttons. But they should also loadMovie in mcs like mc1 with mouse movement.

                                          is possible to adjust the code below to a single action to be applied to buttons? i put both codes here.

                                          If not possible to join it in one single action to button, is possible to make the button’s code to talk with the correspondent frame’s code and make it to work (..loading a big image on mc with mouse movement from the button’s click)?

                                          on (release) {
                                          gotoAndStop("illustra1");
                                          mc2.loadMovie("img/portfolio/illustrations/theapartment1.jpg");
                                          }

                                          moveI = setInterval(moveF, 40);
                                          function moveF() {
                                          targetX = (1-mc1._width/Stage.width)*_xmouse;
                                          mc2._x = .5*(mc1._x+targetX);
                                          updateAfterEvent();
                                          }

                                          • 18. Re: scrolling with mouse movement code
                                            kglad Adobe Community Professional & MVP
                                            are you loading something into mc1, too? if so, mc1._width isn't available until loading is complete so you can't execute moveF() until loading is complete.

                                            • 19. Re: scrolling with mouse movement code
                                              lou_bra Level 1
                                              a bit complicated now

                                              in case i also use mc1 to host all the images that load from the buttons, should i place again a new instance of mc1 in another frame with label to load them, right?

                                              in that case this new frame cointain NO action. the action you gave goes to each button only, right?

                                              should i put "mc1" all the places you put "mc" in the code, and the places with "mcX" should i put "mc1X" or just leave it?

                                              sorry so many questions.. i was going to create a new mc to load images, but i can use mc1 as well if u think it makes things easier, if i know how to place this code.

                                              thanks a lot
                                              • 20. Re: scrolling with mouse movement code
                                                kglad Adobe Community Professional & MVP
                                                you can use the same target movieclip (mc1) for all the loads. just replace mcX with mc1 in the onRelease function.
                                                • 21. Re: scrolling with mouse movement code
                                                  lou_bra Level 1
                                                  i'm using this code. "mini17" is the instance name of one of the buttons. in the other places mcx and mc were replaced with "mc1" see if correct

                                                  the code should be placed in each button or in the frame who contains the "mc1"??

                                                  or part one and part other??



                                                  mini17.onRelease=function(){
                                                  mc1.loadMovie("img/portfolio/illustrations/theapartment1.jpg");
                                                  clearInterval(preloadI);
                                                  preloadI=setInterval(preloadF,100,mc1);
                                                  }

                                                  function preloadF(mc1){
                                                  if(mc1.getBytesLoaded()>0&&mc1.getBytesLoaded()>=mc1.getBytesTotal()){
                                                  clearInterval(preloadI);
                                                  clearInterval(moveI);
                                                  moveI = setInterval(moveF, 40,mc1);
                                                  }
                                                  }

                                                  function moveF(mc1) {
                                                  targetX = (747/Stage.width-mc1._width/Stage.width)*_xmouse;
                                                  mc1._x = .5*(mc1._x+targetX);
                                                  updateAfterEvent();
                                                  }
                                                  • 22. Re: scrolling with mouse movement code
                                                    kglad Adobe Community Professional & MVP
                                                    only the onRelease() code should be (re)applied to each button. one preloadF() and one moveF() is enough.
                                                    • 23. Re: scrolling with mouse movement code
                                                      lou_bra Level 1
                                                      When i place this code in the button comes an error: statement must appear on handler

                                                      mini17.onRelease=function(){
                                                      mc1.loadMovie("img/portfolio/illustrations/theapartment1.jpg");
                                                      clearInterval(preloadI);
                                                      preloadI=setInterval(preloadF,100,mc1);
                                                      }

                                                      and

                                                      "one preloadF() and one moveF() is enough"

                                                      it means it should be applyed only once at the FRAME who contains the mc1 or this is a MC ACTION?
                                                      • 24. Re: scrolling with mouse movement code
                                                        kglad Adobe Community Professional & MVP
                                                        that code should be attached to a frame (that contains mini17), not to an object.

                                                        preloadF() and moveF() can be anywhere as long as they execute before any button releases.
                                                        • 25. Re: scrolling with mouse movement code
                                                          lou_bra Level 1
                                                          hello kglad and sorry the delay

                                                          i placed the action in the frame who contains the buttons, and now is working good.

                                                          images load inside mc1 with mouse movement but without respecting the limited area (747px) for some strange reason that other code does not work, i cant see why.

                                                          i ll keep old action for mouse movement only to mc1.

                                                          i ll use this other action you sent me to load images inside a new mc (mc2) without mouse movement.

                                                          problem is: loadMovie should load as well a oneline text behind each image. Each text (a tittle) is different depending of the image which loads.

                                                          is possible to complement the action below to load also a line of text behing the image? i can latter complement it to all buttons. just need the first one as model. and sorry taking so much of you time, really.

                                                          i place here the code u gave i'm using:

                                                          mini17.onRelease=function(){
                                                          mc2.loadMovie("img/portfolio/illustrations/thesanctuary.jpg");
                                                          clearInterval(preloadI);
                                                          preloadI=setInterval(preloadF,100,mc2);
                                                          }
                                                          • 26. Re: scrolling with mouse movement code
                                                            kglad Adobe Community Professional & MVP
                                                            where's the text that corresponds to each image?
                                                            • 27. Re: scrolling with mouse movement code
                                                              lou_bra Level 1
                                                              hello

                                                              u can use as exemple any text you want. One of the titles are:

                                                              Aquarium
                                                              2007

                                                              The important thing is to have something in the code to provide the function of loading one text to each image who loads. my idea was having it as model, so then i can complete de action to all buttons.. "mini17" corresponds to one text.. "mini18" who loads another image should load another text behind the image.

                                                              with the code you gave me i can already load diferent images at the same mc. now the action should be able to upload a title.. i can insert one by one the title correspondent to each button in the general code latter.

                                                              that's it

                                                              thank you
                                                              • 28. Re: scrolling with mouse movement code
                                                                lou_bra Level 1
                                                                hello

                                                                u can use as exemple any text you want. One of the titles are:

                                                                Aquarium
                                                                2007

                                                                The important thing is to have something in the code to provide the function of loading one text to each image who loads. my idea was having it as model, so then i can complete de action to all buttons.. "mini17" corresponds to one text.. "mini18" who loads another image should load another text behind the image.

                                                                with the code you gave me i can already load diferent images at the same mc. now the action should be able to upload a title.. i can insert one by one the title correspondent to each button in the general code latter.

                                                                that's it

                                                                thank you
                                                                • 29. Re: scrolling with mouse movement code
                                                                  kglad Adobe Community Professional & MVP
                                                                  there has to be something that indicates what text goes with what image. that could either be hard-coded into an array or arrays or it could be in an xml file.
                                                                  • 30. Re: scrolling with mouse movement code
                                                                    lou_bra Level 1
                                                                    that is certainly something I cant do myself. programmer’s stuff for sure.

                                                                    i let this suggestion to next version of flash. It’s really a good thing having easy pre-built functions, like loadMovie but to texts we cold specify in the code.

                                                                    thanks a lot anyway for your help and attention.
                                                                    • 31. Re: scrolling with mouse movement code
                                                                      lou_bra Level 1
                                                                      that is certainly something I cant do myself. programmer’s stuff for sure.

                                                                      i let this suggestion to next version of flash. It’s really a good thing having easy pre-built functions, like loadMovie but to texts we cold specify in the code.

                                                                      thanks a lot anyway for your help and attention.
                                                                      • 32. Re: scrolling with mouse movement code
                                                                        kglad Adobe Community Professional & MVP
                                                                        you're welcome.