# Stage event help

**URL:** <https://forum.kirupa.com/t/stage-event-help/303090>\
**Category:** Uncategorized\
**Created:** [January 13, 2010, 7:54pm UTC](https://forum.kirupa.com/t/stage-event-help/303090 "2010-01-13T19:54:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Navarone](https://avatars.discourse-cdn.com/v4/letter/n/f9ae1b/32.png) [@Navarone](https://forum.kirupa.com/u/Navarone)\
**Post date:** [January 13, 2010, 7:54pm UTC](https://forum.kirupa.com/t/stage-event-help/303090/1 "2010-01-13T19:54:59Z")

</div>

I have a custom scroll bar with two buttons on each end and a dragger. My dragger works well but my buttons do not. When I mouse up the content resets to the last x position of my dragger. So if I don’t do any dragging and I click my scrollLeft button it advanced 50 to the left but as soon as I move the mouse the content resets. I think it’s a problem with my stage event listeners but I am not sure or even how to resolve this issue. I attached a zip file as well. Any help on this appreciated.

```
 ActionScript Code:
 [LEFT]scrollBar_mc.[COLOR=#000080]scrollLeft[/COLOR].[COLOR=#000080]addEventListener[/COLOR][COLOR=#000000]([/COLOR]MouseEvent.[COLOR=#000080]CLICK[/COLOR], moveLeft, [COLOR=#000000] **false** [/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000000] **true** [/COLOR][COLOR=#000000])[/COLOR];

```

scrollBar\_mc.[COLOR=#000080]scrollRight[/COLOR].[COLOR=#000080]addEventListener[/COLOR][COLOR=#000000]([/COLOR]MouseEvent.[COLOR=#000080]CLICK[/COLOR], moveRight, [COLOR=#000000] **false** [/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000000] **true** [/COLOR][COLOR=#000000])[/COLOR];

[COLOR=#000000] **function** [/COLOR] moveLeftCOLOR=#000000[/COLOR]:[COLOR=#0000ff]void[/COLOR] [COLOR=#000000]{[/COLOR]  
mcHolder.[COLOR=#000080]x[/COLOR] -= [COLOR=#000080]50[/COLOR];  
[COLOR=#000000]}[/COLOR]

[COLOR=#000000] **function** [/COLOR] moveRightCOLOR=#000000[/COLOR]:[COLOR=#0000ff]void[/COLOR] [COLOR=#000000]{[/COLOR]  
[COLOR=#0000ff]if[/COLOR] [COLOR=#000000]([/COLOR]mcHolder.[COLOR=#000080]x[/COLOR] != [COLOR=#000080]25[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]  
mcHolder.[COLOR=#000080]x[/COLOR] += [COLOR=#000080]50[/COLOR];  
[COLOR=#000000]}[/COLOR]  
[COLOR=#000000]}[/COLOR]

[COLOR=#000000] **function** [/COLOR] scrollColorContentCOLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
[COLOR=#808080]_// Set variables_[/COLOR]  
[COLOR=#000000] **var** [/COLOR] scrollbarWidth:[COLOR=#0000ff]Number[/COLOR] = scrollBar\_mc.[COLOR=#000080]scrollMask[/COLOR].[COLOR=#0000ff]width[/COLOR];  
[COLOR=#000000] **var** [/COLOR] scrollDraggerWidth:[COLOR=#0000ff]Number[/COLOR] = scrollBar\_mc.[COLOR=#000080]scrollDragger[/COLOR].[COLOR=#0000ff]width[/COLOR];  
[COLOR=#000000] **var** [/COLOR] maskWidth:[COLOR=#0000ff]Number[/COLOR] = scrollBar\_mc.[COLOR=#000080]scrollMask[/COLOR].[COLOR=#0000ff]width[/COLOR];  
[COLOR=#000000] **var** [/COLOR] leftBound:[COLOR=#0000ff]Number[/COLOR] = scrollBar\_mc.[COLOR=#000080]scrollMask[/COLOR].[COLOR=#000080]x[/COLOR];  
[COLOR=#000000] **var** [/COLOR] rightBound:[COLOR=#0000ff]Number[/COLOR] = scrollBar\_mc.[COLOR=#000080]scrollMask[/COLOR].[COLOR=#000080]width[/COLOR]-scrollDraggerWidth;  
[COLOR=#000000] **var** [/COLOR] startPos:[COLOR=#0000ff]Number[/COLOR] = mcHolder.[COLOR=#000080]x[/COLOR];  
[COLOR=#000000] **var** [/COLOR] absNumSet:[COLOR=#0000ff]Number[/COLOR] = [COLOR=#000080]60[/COLOR].[COLOR=#000080]5[/COLOR];  
[COLOR=#808080]_//set starting position of dragger_[/COLOR]  
scrollBar\_mc.[COLOR=#000080]scrollDragger[/COLOR].[COLOR=#000080]x[/COLOR] = scrollBar\_mc.[COLOR=#000080]scrollMask[/COLOR].[COLOR=#000080]x[/COLOR];

```
[COLOR=#808080]*// Event Listeners*[/COLOR]
scrollBar_mc.[COLOR=#000080]scrollDragger[/COLOR].[COLOR=#000080]addEventListener[/COLOR][COLOR=#000000]([/COLOR]MouseEvent.[COLOR=#000080]MOUSE_DOWN[/COLOR], scrollDraggerPress, [COLOR=#000000] **false** [/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000000] **true** [/COLOR][COLOR=#000000])[/COLOR];
scrollBar_mc.[COLOR=#000080]scrollDragger[/COLOR].[COLOR=#000080]addEventListener[/COLOR][COLOR=#000000]([/COLOR]MouseEvent.[COLOR=#000080]MOUSE_UP[/COLOR], mouseUpOnStage, [COLOR=#000000] **false** [/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000000] **true** [/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#0000ff]stage[/COLOR].[COLOR=#000080]addEventListener[/COLOR][COLOR=#000000]([/COLOR]MouseEvent.[COLOR=#000080]MOUSE_UP[/COLOR], mouseUpOnStage[COLOR=#000000])[/COLOR];    

[COLOR=#808080]*// When scrollDragger gets pressed we do this*[/COLOR]
[COLOR=#000000] **function** [/COLOR] scrollDraggerPress[COLOR=#000000]([/COLOR]event:MouseEvent[COLOR=#000000])[/COLOR]:[COLOR=#0000ff]void[/COLOR] [COLOR=#000000]{[/COLOR]
    [COLOR=#000000] **var** [/COLOR] contentWidth:[COLOR=#0000ff]Number[/COLOR] = mcHolder.[COLOR=#0000ff]width[/COLOR];
    [COLOR=#000000] **var** [/COLOR] scrollAmount:[COLOR=#0000ff]Number[/COLOR] = [COLOR=#000000]([/COLOR]contentWidth-maskWidth[COLOR=#000000])[/COLOR]/[COLOR=#000000]([/COLOR]scrollbarWidth-scrollDraggerWidth[COLOR=#000000])[/COLOR];        
    [COLOR=#808080]*// Set bounds using some of the scroller BG properties claimed above*[/COLOR]
    [COLOR=#000000] **var** [/COLOR] bounds:Rectangle = [COLOR=#000000] **new** [/COLOR] Rectangle[COLOR=#000000]([/COLOR]leftBound, [COLOR=#000080]60[/COLOR].[COLOR=#000080]5[/COLOR], rightBound[COLOR=#000000])[/COLOR];
    scrollBar_mc.[COLOR=#000080]scrollDragger[/COLOR].[COLOR=#0000ff]startDrag[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000] **false** [/COLOR], bounds[COLOR=#000000])[/COLOR];
    [COLOR=#0000ff]stage[/COLOR].[COLOR=#000080]addEventListener[/COLOR][COLOR=#000000]([/COLOR]MouseEvent.[COLOR=#000080]MOUSE_MOVE[/COLOR], reportStageMouse[COLOR=#000000])[/COLOR];        
    [COLOR=#000000] **function** [/COLOR] reportStageMouse[COLOR=#000000]([/COLOR]event:MouseEvent[COLOR=#000000])[/COLOR]:[COLOR=#0000ff]void[/COLOR] [COLOR=#000000]{[/COLOR]
        absNumSet = [COLOR=#0000ff]Math[/COLOR].[COLOR=#0000ff]abs[/COLOR][COLOR=#000000]([/COLOR]scrollBar_mc.[COLOR=#000080]scrollMask[/COLOR].[COLOR=#000080]x[/COLOR] - scrollBar_mc.[COLOR=#000080]scrollDragger[/COLOR].[COLOR=#000080]x[/COLOR][COLOR=#000000])[/COLOR];            
        mcHolder.[COLOR=#000080]x[/COLOR] = + [COLOR=#0000ff]Math[/COLOR].[COLOR=#0000ff]round[/COLOR][COLOR=#000000]([/COLOR]absNumSet * - [COLOR=#000080]1[/COLOR] * scrollAmount + startPos[COLOR=#000000])[/COLOR];                
    [COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]    

[COLOR=#808080]*// When mouse is released while dragging we do this*[/COLOR]
[COLOR=#000000] **function** [/COLOR] mouseUpOnStage[COLOR=#000000]([/COLOR]event:MouseEvent[COLOR=#000000])[/COLOR]:[COLOR=#0000ff]void[/COLOR] [COLOR=#000000]{[/COLOR]        
    [COLOR=#0000ff]stopDrag[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];            
[COLOR=#000000]}[/COLOR]

```

[COLOR=#000000]}[/COLOR]

scrollColorContentCOLOR=#000000[/COLOR];  
[/LEFT]
