A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: pannorama panning

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    10

    pannorama panning

    Hello all this is my first post here.

    I am trying to create a simple panorama viewer. the direction is governed by two mouse over areas one on each side of the stage (both will be invisible), at present the left side animates the background panorama right by 10 and the right side animates the panorama left by -10.

    This essentially means it multiplies its speed if i mouse over the same edge twice, this is a problem i wish to fix, i also notice that if i go from one edge of the screen to the other it animates and stops, if we look at this from a maths point of view.

    -10 moves left ( if mouse moves too right mouse over edge) +10 this = 0 value or in other words stops animation, then i have to mouse over again to +10 to make value 10 eg move right. this mouse over twice thing is not what i want.

    To fix both issues, i think it would be best to place a mouse over area between both left and right that zeros out the value. so the middle will always stop the animation. though id not know how to zero out the value.

    here take a look at my code so far



    scroll_L.addEventListener(MouseEvent.MOUSE_OVER, f2_MouseOverHandler_2);

    function f2_MouseOverHandler_2(event:MouseEvent):void
    {
    bg_mc.addEventListener(Event.ENTER_FRAME, f2_AnimateHorizontally_3);

    function f2_AnimateHorizontally_3(event:Event)
    {
    bg_mc.x += -10;
    }
    }



    Scroll_R.addEventListener(MouseEvent.MOUSE_OVER, fl_MouseOverHandler_4);

    function fl_MouseOverHandler_4(event:MouseEvent):void
    {
    bg_mc.addEventListener(Event.ENTER_FRAME, fl_AnimateHorizontally_4);

    function fl_AnimateHorizontally_4(event:Event)
    {
    bg_mc.x += 10;
    }
    }





    I hope this all makes sense.

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Post code using [code] tags.

    You don't need two different enter frame listeners. What you need to do is have a variable for the x increment to apply on each frame. On the left button, set that to -10, on the right, 10, and if you want a stop button, set it to 0 in there.
    Then, in your single enter frame handler, simply add xinc to the bg_mc.x value.

    Code:
    var xinc:int = 0;
    bg_mc.addEventListener(Event.ENTER_FRAME, animateHorizontally);
    scroll_L.addEventListener(MouseEvent.MOUSE_OVER, f2_MouseOverHandler_2);
    
    function f2_MouseOverHandler_2(event:MouseEvent):void{
      xinc = -10
    }
    
    scroll_R.addEventListener(MouseEvent.MOUSE_OVER, fl_MouseOverHandler_4);
    
    function fl_MouseOverHandler_4(event:MouseEvent):void{
      xinc = 10;
    }
    
    stopArea.addEventListener(MouseEvent.MOUSE_OVER, neutralize);
    function neutralize(e:Event):void{
      xinc = 0;
    }
    
    function animateHorizontally(event:Event):void{
      bg_mc.x += xinc;
    }
    I don't know what's up with your crazy function names or inconsistent capitalization. Also, there was no need to nest your functions.

  3. #3
    Junior Member
    Join Date
    Nov 2011
    Posts
    10
    Thank you for all your help. im sorry the reply is so late, also out of interest, is there a way to load another panorama to attach to it, im trying to make this viewer show alot of long images and make it loop (as if it where almost infinite).

    ps. im dyslexic so im not great with capitalizations :/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center