Scrolling TextField please help

Hello I am creating a dynamic text field that can be scrolled.

It is working but only problem is when I drag the sroller or click up or down button the text start srolling but now I want to add a stage event listener to check when the mouse moves up on the stage and that means the user have stoped dragging.

I can implelement stage.addEventListener(MouseEvent.MOUSE_UP, endDrag); fine when I have the code on the main timeline but when I move it into a class and add it there it give me an error saying null object reference

can any one please tell me how to resolve this I am attaching the fla and the class file

PS

the only problem is

stage.addEventListener(Mouse.MOUSE_UP, endDrag); inside ScrollBar class

If I remove this line the code works without any error. but there is no way then to stop draging once the user moves to other parts of stage.

add that listener on Mouse.MOUSE_DOWN and remove it when not necassary

Oh man you are a real life saver thank you so much. it is working now. But can you please tell me what wouldn’t it work in the constructor?

Just one more thing if you dont mind at the moment when I click up or down buttons the text scroll but I have to keep clicking them to scroll the text is there a way that when I click and hold down buttons the text keep scrolling down until it finishes.

Thanks again

1 - http://www.kirupa.com/forum/showthread.php?p=1952513#post1952513
2 - create a Timer

Hi Felixz

Thank you ever so much I got my answer to the first question about stage.

Didn;t get the second one but I am not worrying about that so thank you for all your help
Really Appreciate it

var timer:Timer=new Timer(300,0);
timer.addEventListener(TimerEvent.TIMER,scrollOneDown);

on MOUSE_DOWN:

timer.start()

on MOUSE_UP:

timer.stop();
timer.reset();

Thanks Felixz

That makes sense. I will work on it.

Sorry just one other thing remember you told me how to perform button clicks by passing reference to the clicked button. that works fine when I click some button but how can I have one button already clicked when the application starts like I want the home button already clicked when my website loads.

I hope I am making sense. Can I just dipatch a click event for home buttons the first time website loads?

y

because when first time a website starts it loads the home page but in this case I have to click the home button to get the contents. If I load the home contents in the start without clicking the button so it is not disable and the user can click it and the home contents will load again which is not very efficient.

homeButton.dispatchEvent(new MouseEvent(MouseEvent.CLICK));

Brilliant thank you.
Really Appreciate it.