Quantcast
Channel: Adobe Community : All Content - All Communities
Viewing all articles
Browse latest Browse all 290743

scroll bar breaks timeline navigations

$
0
0

So I have a project where I have a custom scrollbar and it scrolls conent in a masked region. The only content is a movie clip symbol named "content" and inside of it, it has several button symbols that, when clicked, navigate the timeline. Everything works fine until the scrollbar is moved via using the mouse to scroll the content. Once that happens, the buttons no longer respond to their commands that I have told them to do.

 

I cannot figure out where I went wrong, I figure it has to do with code relating to the "thumb" symbol, which is the small bit used to scroll with. Because once clicked it causes the issues. But I cannot be sure. It is driving me mad.

 

stop();

import flash.events.MouseEvent;

 

var yOffset:Number;

var topLimit:Number = track.y;

var thumbRange:Number = track.height - thumb.height;

var bottomLimit:Number = track.y + thumbRange;

//new variable: scrollPercent!

var scrollPercent:Number = 0;

var contentRange:Number = content.height - window.height;

 

content.mask = window;

thumb.buttonMode = true;

thumb.addEventListener(MouseEvent.MOUSE_DOWN, thumb_onMouseDown);

function thumb_onMouseDown(event:MouseEvent):void {

    yOffset = mouseY - thumb.y;

    stage.addEventListener(MouseEvent.MOUSE_MOVE, stage_onMouseMove);

    stage.addEventListener(MouseEvent.MOUSE_UP, stage_onMouseUp);

}

 

function stage_onMouseMove(event:MouseEvent):void {

    thumb.y = mouseY - yOffset;

    //restrict the movement of the thumb:

    if(thumb.y < topLimit) {

        thumb.y = topLimit;

    }

    if(thumb.y > bottomLimit) {

        thumb.y = bottomLimit;

    }

    //calculate scrollPercent and make it do stuff:

    scrollPercent = (thumb.y - track.y) / thumbRange;

    content.y = window.y - (scrollPercent * contentRange);

    event.updateAfterEvent();

}

 

function stage_onMouseUp(event:MouseEvent):void {

    stage.removeEventListener(MouseEvent.MOUSE_MOVE, stage_onMouseMove);

    stage.removeEventListener(MouseEvent.MOUSE_UP, stage_onMouseUp);

}

 

content.joltik_btn.addEventListener(MouseEvent.CLICK, playframe);

 

function playframe(event:MouseEvent):void

{

    gotoAndPlay(2);

   

}

 

home_btn.addEventListener(MouseEvent.CLICK, playframe2);

 

function playframe2(event:MouseEvent):void

{

    gotoAndPlay(13);

}

 

 

 

 

The code for the custom scroll bar for content I used from

 

http://theflashconnection.com/content/scrolling-right-along-now


Viewing all articles
Browse latest Browse all 290743

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>