So first off, you need a movieClip to use as the scroll bar and a movieClip to use for the bit that you slide up and down. You need your dynamic text field and unless this is going to fill the screen you will have a mask so only a certain area of the field is showing. Now when your movie loads the text field needs to be the same size as the mask/area that is going to be showing so if you've more text than you can fit in i'd start with an empty text field and add the text with AS (or do the scrolling a different way).
You need to make sure that the scroll bar and the mask are the same height and y value and make sure the slider is also aligned to this y value and (obviously) on the layer above the scroll bar. Then set these variables, changing the values for the names of your movieclips/text field:
- Code: Select all
var scrollBar:MovieClip = theRelativeInstanceNameOfYourScrollBar;
var scrollSlider:MovieClip = theRelativeInstanceNameOfYourSlider;
var scrollingText:TextField = theRelativeInstanceNameOfYourTextField;
Then add this code
- Code: Select all
var myRect:Rectangle = new Rectangle(scrollSlider.x, scrollSlider.y, 0, scrollBar.height - scrollSlider.height);
function dragSlider(event:MouseEvent):void {
event.target.startDrag(false, myRect);
}
function releaseSlider(event:MouseEvent):void {
event.target.stopDrag();
}
function scrollFunction(event:Event):void {
var sliderHeight:int = scrollBar.height - scrollSlider.height;
var documentHeight:int = scrollingText.maxScrollV;
var distribution:Number = documentHeight/sliderHeight;
var currentHeight:int =scrollSlider.y;
var relativeHeight:Number = currentHeight-scrollBar.y;
var movement:Number = relativeHeight*distribution;
scrollingText.scrollV = movement;
}
scrollSlider.addEventListener(MouseEvent.MOUSE_DOWN, dragSlider);
scrollSlider.addEventListener(MouseEvent.MOUSE_UP, releaseSlider);
scrollBar.addEventListener(Event.ENTER_FRAME, scrollFunction);
And that should work i hope. I know i am not great at explanations but i hope this will be of some use to somebody, feel free to ask questions. Here is mine: I couldn't get the swf to work properly so heres a link)
http://home.wlv.ac.uk/~in0238/accessabilityWindow.html
If anyone is intrested in the code to do the colour/text changes just say.
UA



