dcsimg
A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: [RESOLVED] looping horizontal thumbnail scroll

  1. #1
    Member
    Join Date
    Sep 2008
    Posts
    39

    resolved [RESOLVED] looping horizontal thumbnail scroll

    Hey,
    I have a bunch of thumbnails that i have a left and right scroll button for. It works great but when you get to the last image i want it to loop to the first one not just stop at the end.

    Here's some of my code let me know if you need more.
    Thanks so much, I know it's something stupid. I'm still learning.
    Thanks!
    function addScrollListeners():void {
    right.addEventListener(MouseEvent.MOUSE_DOWN,start Scroll);
    right.addEventListener(MouseEvent.MOUSE_UP, stopScroll);
    left.addEventListener(MouseEvent.MOUSE_DOWN,startS croll);
    left.addEventListener(MouseEvent.MOUSE_UP, stopScroll);
    }
    //handlers that either add or delete the scroll enterframe event
    function startScroll(e:MouseEvent):void {
    thumbMask_mc.addEventListener(Event.ENTER_FRAME, scrollThumbs);
    }

    function stopScroll(event:MouseEvent):void {
    thumbMask_mc.removeEventListener(Event.ENTER_FRAME , scrollThumbs);
    }



    //the scrollThumbs function
    //making it scroll left and right
    function scrollThumbs(event:Event):void {
    holder_mc.x += Math.cos((-thumbMask_mc.mouseX/scrollPaneWidth)*Math.PI)*scrollSpeed;
    if (holder_mc.x>scrollPaneX) {
    holder_mc.x=scrollPaneX;
    trace("seft");
    //above code controls left arrow
    }
    if (-holder_mc.x>(holder_mc.width-scrollPaneWidth-scrollPaneX)) {
    holder_mc.x = -(holder_mc.width-scrollPaneWidth-scrollPaneX);
    trace("right");
    //above code controls right arrow

    }

    }

  2. #2
    lemon juice hurts your eyes florianvanthuyn's Avatar
    Join Date
    Jul 2005
    Location
    Merelbeke, Belgium
    Posts
    546
    I think your looking at either moving the thumbs that have left the masked area to the back or front (depending on the direction) or having a duplicate of holder_mc and add it to the back.
    Florian Vanthuyne

    WAR AGAINST SOLVED THREADS
    mark yours as Resolved under Thread Tools!

  3. #3
    Member
    Join Date
    Sep 2008
    Posts
    39
    Quote Originally Posted by florianvanthuyn View Post
    I think your looking at either moving the thumbs that have left the masked area to the back or front (depending on the direction) or having a duplicate of holder_mc and add it to the back.
    It's all pulled in from an xml file, so i'm not sure that i should but two in. So I probably need to figure out the math to tell the holder_mc to start over?

    (I've been on vacation for a week and 1/2 and it's hard to get back into things haha)

  4. #4
    lemon juice hurts your eyes florianvanthuyn's Avatar
    Join Date
    Jul 2005
    Location
    Merelbeke, Belgium
    Posts
    546
    In that case a duplicate will be of no use, unless you're ok with adding all the actions twice (which shouldn't be a problem if you're assigning them with a loop, but still)..

    I would move the individual thumbnails, rather than the container, so in your ENTER_FRAME function, call for a function in which the thumbnails are iterated and moved .
    In that same function you check to see if the thumb the loop is looking at has an xpos smaller than it's minimum position or one bigger than it's maximum position, and then you just put it at the end or beginning of the row of thumbnails, depending on the direction.
    Florian Vanthuyne

    WAR AGAINST SOLVED THREADS
    mark yours as Resolved under Thread Tools!

  5. #5
    Member
    Join Date
    Sep 2008
    Posts
    39
    Quote Originally Posted by florianvanthuyn View Post
    In that case a duplicate will be of no use, unless you're ok with adding all the actions twice (which shouldn't be a problem if you're assigning them with a loop, but still)..

    I would move the individual thumbnails, rather than the container, so in your ENTER_FRAME function, call for a function in which the thumbnails are iterated and moved .
    In that same function you check to see if the thumb the loop is looking at has an xpos smaller than it's minimum position or one bigger than it's maximum position, and then you just put it at the end or beginning of the row of thumbnails, depending on the direction.
    Ok i'll check the individual thumbnail thing I guess I just have to base everything off of the position of the 1st and last ... since there could be a lot of them or just one ... Ok Great that gives me something to go with!

  6. #6
    Member
    Join Date
    Sep 2008
    Posts
    39
    I decided doing this wasn't necessary BUT Thanks! I'm sure i'll have to do this eventually and now i know how

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