# External SWF actionscript problem

**URL:** <https://forum.kirupa.com/t/external-swf-actionscript-problem/306182>\
**Category:** flash\
**Created:** [March 10, 2010, 10:10pm UTC](https://forum.kirupa.com/t/external-swf-actionscript-problem/306182 "2010-03-10T22:10:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![RossKidd](https://avatars.discourse-cdn.com/v4/letter/r/53a042/32.png) [@RossKidd](https://forum.kirupa.com/u/RossKidd)\
**Post date:** [March 10, 2010, 10:10pm UTC](https://forum.kirupa.com/t/external-swf-actionscript-problem/306182/1 "2010-03-10T22:10:39Z")

</div>

I am using Lee Brimelow’s oop scrollbar.

[http://www.gotoandlearn.com/play?id=72](http://www.gotoandlearn.com/play?id=72)

This works on its own but when I try and load it as am external movieclip the scrollbar stops working.

my external swf is added to the stage and cast as a movieclip with.

var externalMovie = MovieClip(loader.content);

I think the line

stage.addEventListener(MouseEvent.MOUSE\_MOVE, thumbMove);

may be the problem. How do I reference the stage from an external MC?

Many thanks.

full as code below

```auto
package com.leebrimelow.ui
{
    import flash.display.*;
    import flash.events.*;
    
    public class ScrollBar extends MovieClip
    {
        private var yOffset:Number;
        private var yMin:Number;
        private var yMax:Number;
        
        public function ScrollBar():void
        {
            yMin = 0;
            yMax = track.height - thumb.height;
            thumb.addEventListener(MouseEvent.MOUSE_DOWN, thumbDown);
            stage.addEventListener(MouseEvent.MOUSE_UP, thumbUp);
        }
        
        private function thumbDown(e:MouseEvent):void
        {
            stage.addEventListener(MouseEvent.MOUSE_MOVE, thumbMove);
            yOffset = mouseY - thumb.y;
        }

        private function thumbUp(e:MouseEvent):void
        {
            stage.removeEventListener(MouseEvent.MOUSE_MOVE, thumbMove);
        }

        private function thumbMove(e:MouseEvent):void
        {
            thumb.y = mouseY - yOffset;
            if(thumb.y <= yMin)
                thumb.y = yMin;
            if(thumb.y >= yMax)
                thumb.y = yMax;
            dispatchEvent(new ScrollBarEvent(thumb.y / yMax));
            e.updateAfterEvent();
        }
    }
}

```

```auto

package com.leebrimelow.ui
{
    import flash.events.*;
    
    public class ScrollBarEvent extends Event
    {
        public static const VALUE_CHANGED = "valueChanged";
        public var scrollPercent:Number;
        
        public function ScrollBarEvent(sp:Number):void
        {
            super(VALUE_CHANGED);
            scrollPercent = sp;
        }
        
    }
}

```

```auto
package com.leebrimelow.ui
{
    import flash.display.*;
    import flash.events.*;
    import caurina.transitions.*;
    
    public class ScrollBox extends MovieClip
    {        
        public function ScrollBox():void
        {
            sb.addEventListener(ScrollBarEvent.VALUE_CHANGED, sbChange);
        }
        
        private function sbChange(e:ScrollBarEvent):void
        {
            Tweener.addTween(content, {y:(-e.scrollPercent*(content.height-masker.height)),
                               time:1});
        }
    }
}

```
