# Scrolling TextField please help

**URL:** <https://forum.kirupa.com/t/scrolling-textfield-please-help/260460>\
**Category:** flash\
**Created:** [May 15, 2008, 8:19pm UTC](https://forum.kirupa.com/t/scrolling-textfield-please-help/260460 "2008-05-15T20:19:32Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![adnan794](https://avatars.discourse-cdn.com/v4/letter/a/8edcca/32.png) [@adnan794](https://forum.kirupa.com/u/adnan794)\
**Post date:** [May 15, 2008, 8:19pm UTC](https://forum.kirupa.com/t/scrolling-textfield-please-help/260460/1 "2008-05-15T20:19:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![adnan794](https://avatars.discourse-cdn.com/v4/letter/a/8edcca/32.png) [@adnan794](https://forum.kirupa.com/u/adnan794)\
**Post date:** [May 15, 2008, 8:31pm UTC](https://forum.kirupa.com/t/scrolling-textfield-please-help/260460/2 "2008-05-15T20:31:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Felixz](https://avatars.discourse-cdn.com/v4/letter/f/ecb155/32.png) [@Felixz](https://forum.kirupa.com/u/Felixz)\
**Post date:** [May 15, 2008, 8:35pm UTC](https://forum.kirupa.com/t/scrolling-textfield-please-help/260460/3 "2008-05-15T20:35:56Z")

</div>

add that listener on Mouse.MOUSE\_DOWN and remove it when not necassary

---

<div class="post-metadata">

**Author:** ![adnan794](https://avatars.discourse-cdn.com/v4/letter/a/8edcca/32.png) [@adnan794](https://forum.kirupa.com/u/adnan794)\
**Post date:** [May 15, 2008, 8:44pm UTC](https://forum.kirupa.com/t/scrolling-textfield-please-help/260460/4 "2008-05-15T20:44:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Felixz](https://avatars.discourse-cdn.com/v4/letter/f/ecb155/32.png) [@Felixz](https://forum.kirupa.com/u/Felixz)\
**Post date:** [May 15, 2008, 9:05pm UTC](https://forum.kirupa.com/t/scrolling-textfield-please-help/260460/5 "2008-05-15T21:05:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![adnan794](https://avatars.discourse-cdn.com/v4/letter/a/8edcca/32.png) [@adnan794](https://forum.kirupa.com/u/adnan794)\
**Post date:** [May 15, 2008, 9:28pm UTC](https://forum.kirupa.com/t/scrolling-textfield-please-help/260460/6 "2008-05-15T21:28:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Felixz](https://avatars.discourse-cdn.com/v4/letter/f/ecb155/32.png) [@Felixz](https://forum.kirupa.com/u/Felixz)\
**Post date:** [May 16, 2008, 11:32am UTC](https://forum.kirupa.com/t/scrolling-textfield-please-help/260460/7 "2008-05-16T11:32:33Z")

</div>

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

```

on MOUSE\_DOWN:

```auto
timer.start()

```

on MOUSE\_UP:

```auto
timer.stop();
timer.reset();

```

---

<div class="post-metadata">

**Author:** ![adnan794](https://avatars.discourse-cdn.com/v4/letter/a/8edcca/32.png) [@adnan794](https://forum.kirupa.com/u/adnan794)\
**Post date:** [May 16, 2008, 1:19pm UTC](https://forum.kirupa.com/t/scrolling-textfield-please-help/260460/8 "2008-05-16T13:19:57Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Felixz](https://avatars.discourse-cdn.com/v4/letter/f/ecb155/32.png) [@Felixz](https://forum.kirupa.com/u/Felixz)\
**Post date:** [May 16, 2008, 1:24pm UTC](https://forum.kirupa.com/t/scrolling-textfield-please-help/260460/9 "2008-05-16T13:24:09Z")

</div>

y

---

<div class="post-metadata">

**Author:** ![adnan794](https://avatars.discourse-cdn.com/v4/letter/a/8edcca/32.png) [@adnan794](https://forum.kirupa.com/u/adnan794)\
**Post date:** [May 16, 2008, 1:49pm UTC](https://forum.kirupa.com/t/scrolling-textfield-please-help/260460/10 "2008-05-16T13:49:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Felixz](https://avatars.discourse-cdn.com/v4/letter/f/ecb155/32.png) [@Felixz](https://forum.kirupa.com/u/Felixz)\
**Post date:** [May 16, 2008, 1:56pm UTC](https://forum.kirupa.com/t/scrolling-textfield-please-help/260460/11 "2008-05-16T13:56:17Z")

</div>

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

```

---

<div class="post-metadata">

**Author:** ![adnan794](https://avatars.discourse-cdn.com/v4/letter/a/8edcca/32.png) [@adnan794](https://forum.kirupa.com/u/adnan794)\
**Post date:** [May 16, 2008, 2:02pm UTC](https://forum.kirupa.com/t/scrolling-textfield-please-help/260460/12 "2008-05-16T14:02:43Z")

</div>

Brilliant thank you.  
Really Appreciate it.
