# Timer \[MX\]

**URL:** https://forum.kirupa.com/t/timer-mx/17162
**Category:** flash
**Created:** [April 1, 2003, 11:57pm UTC](https://forum.kirupa.com/t/timer-mx/17162 "2003-04-01T23:57:13Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![newbieMX](https://avatars.discourse-cdn.com/v4/letter/n/ed655f/32.png) [@newbieMX](https://forum.kirupa.com/u/newbieMX)
#### Post date: [April 1, 2003, 11:57pm UTC](https://forum.kirupa.com/t/timer-mx/17162/1 "2003-04-01T23:57:13Z")

</div>

Umm… I was planning on making a random message appear, but, when I did try it , all appear really quick and were impossible to read. Is there anyway to make a timer in actionscript, for example to make a message change every 5 seconds or so? And also, someone mentioned to me a component, and I’m not a fan of the components, so if anyone can help me out and either give me a url to creating a timer, or be helpful to write down a code :whistle: It would be greatly appreciated…:s:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 2, 2003, 12:18am UTC](https://forum.kirupa.com/t/timer-mx/17162/2 "2003-04-02T00:18:28Z")

</div>

here is the code:

```auto

_root.onEnterFrame = function ()
{
	newTimer = getTimer () / 1000;
	if (newTimer - oldTimer >= 5)
	{
		oldTimer = getTimer () / 1000;
		trace ("now");
	}
};

```

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 2, 2003, 12:19am UTC](https://forum.kirupa.com/t/timer-mx/17162/3 "2003-04-02T00:19:02Z")

</div>

where it says trace(“now”) you would put the command for displaying the new message… the code is pretty self-explanitory…

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 2, 2003, 12:26am UTC](https://forum.kirupa.com/t/timer-mx/17162/4 "2003-04-02T00:26:04Z")

</div>

:s: Thanx Alot man ! Well since I’m really a newbie at actionscript and I only know so much, can you explain more thoroughly what I would have to put inside the trace parenthesis, and what does trace do? If not it’s cool, and thx alot ! 😉

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 2, 2003, 12:31am UTC](https://forum.kirupa.com/t/timer-mx/17162/5 "2003-04-02T00:31:07Z")

</div>

well you would replace trace() with whatever you are using to display your random messages. trace just shows you the value of something, but it only does so inside of flash. once the movie is published it stops working…

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 2, 2003, 12:34am UTC](https://forum.kirupa.com/t/timer-mx/17162/6 "2003-04-02T00:34:36Z")

</div>

:stunned: Oh cool, well now I understand where to place my code ;). Thx for the help man! Now I gotta go to work!:bounce:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 2, 2003, 12:44am UTC](https://forum.kirupa.com/t/timer-mx/17162/7 "2003-04-02T00:44:40Z")

</div>

no problem. post if you need anything else…

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 2, 2003, 1:00am UTC](https://forum.kirupa.com/t/timer-mx/17162/8 "2003-04-02T01:00:30Z")

</div>

Fine if you insist :beam: I was wondering how can i make a draggable scroller, for exampled I know how to make the buttons to scroll text etc. I already know how to do that, what I was wondering how can i make the scroll-bar scroll everytime the user either clicks the button, or they drag the scroll bar to scroll the text… how would i do this? and if its in a site, please post the site’s url 😉 ok cool, hope you can help 🙂

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 2, 2003, 1:09am UTC](https://forum.kirupa.com/t/timer-mx/17162/9 "2003-04-02T01:09:52Z")

</div>

well if you know how to scroll text, then you can check this tutorial and it might help you on your way…

[http://www.kirupa.com/developer/mx/slider.htm](http://www.kirupa.com/developer/mx/slider.htm)

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 2, 2003, 1:13am UTC](https://forum.kirupa.com/t/timer-mx/17162/10 "2003-04-02T01:13:53Z")

</div>

Oh yes the powerful Kirupa Slider, I tried, and since I am a super newbie, I tried to make it scroll text… but failed miserably. Maybe you can be of some help, I’ve only used the sliders to control volume and pan when I add music to my site… but when it comes to scrolling text , it failed… help please :\*(

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 2, 2003, 1:29am UTC](https://forum.kirupa.com/t/timer-mx/17162/11 "2003-04-02T01:29:18Z")

</div>

well I’ll try (haven’t tried yet) and I’ll let you know, but I probably won’t have an answer tonight…

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 2, 2003, 1:30am UTC](https://forum.kirupa.com/t/timer-mx/17162/12 "2003-04-02T01:30:23Z")

</div>

Ok cool man, I really appreciate all the help man. ThX Alot!😉

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 2, 2003, 3:14am UTC](https://forum.kirupa.com/t/timer-mx/17162/13 "2003-04-02T03:14:55Z")

</div>

Ok, here ya go… get ready for this…

```auto
dragger.onPress = function ()
{
	this.startDrag (true, line._x, line._y, line._x, (line._height + line._y)); //drags the bar
	//this.startDrag(
	this.onEnterFrame = function ()
	{
		ratio = Math.round ((this._y - line._y) * 100 / line._height); // finds the ratio. % that the bar has moved on line
		if (Number (scrollableText.scroll) <= Number (scrollableText.maxscroll) && Number (scrollableText.scroll) > 0)
		{
			scrollableText.scroll = ratio * scrollableText.maxscroll / line._height; //scrolls the text
		}
	};
};
dragger.onRelease = dragger.onReleaseOutside = function ()
{
	this.onEnterFrame = function ()
	{
		this._y = ((scrollableText.scroll*(line._height*line._height))/(100*scrollableText.maxscroll))+line._y //moves the drag-box with the scroll of the ttextbox
	};
	stopDrag ();
};
up.onRelease = up.onReleaseOutside = down.onRelease = down.onReleaseOutside = function ()
{
	this.onEnterFrame = null; //turns off the button functions.
};
up.onPress = function ()
{
	this.onEnterFrame = function ()
	{
		currentScroll = scrollableText.scroll;
		if (Number (currentScroll) > 1)
		{
			scrollableText.scroll = currentScroll - 1; //scrolls the text up.
		}
	};
};
down.onPress = function ()
{
	this.onEnterFrame = function ()
	{
		currentScroll = scrollableText.scroll;
		if (Number (currentScroll) < Number (scrollableText.maxscroll))
		{
			scrollableText.scroll = Number (currentScroll) + 1; // scrolls the text down.
		}
	};
};
/*_root.onMouseDown = function () // this function just traces the values of the max and current scroll of the text box.
{
	trace ("max=" + scrollableText.maxscroll);
	trace ("cur=" + scrollableText.scroll);
};*/
scrollableText = "A bunch of text went here "

```

And I attached the file. The code inside the file is identical to this except that the variable “scrollableText” has a lot more text… oh you’ll see when you look at the file…

Im assuming that you’ll have questions so ask away and I will try to help as much as possible…

cheers,  
jubs :cowboy:

happy flashing…

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 2, 2003, 3:16am UTC](https://forum.kirupa.com/t/timer-mx/17162/14 "2003-04-02T03:16:19Z")

</div>

oh ya, I used a combination of these two [kirupa.com](http://kirupa.com) tutorials:

text scroller: [http://www.kirupa.com/developer/flash5/scrolltext.htm](http://www.kirupa.com/developer/flash5/scrolltext.htm)

sliders:  
[http://www.kirupa.com/developer/mx/slider.htm](http://www.kirupa.com/developer/mx/slider.htm)

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 2, 2003, 3:16am UTC](https://forum.kirupa.com/t/timer-mx/17162/15 "2003-04-02T03:16:55Z")

</div>

someone give me a cookie!!!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 2, 2003, 3:22am UTC](https://forum.kirupa.com/t/timer-mx/17162/16 "2003-04-02T03:22:04Z")

</div>

:beam: GREAT! I’ve really been breaking my head to do this, but since im a super newbie at this I’ve had a hard time. Anyways man thnx alot, I’m on my way to trying out the code… and see if I can use it for my site 😉 and I’m pretty sure I’ll have some questions, so I’ll post as soon as i’m done memorizing the code… lolz thats what I do, memorize the codes, thats the only way I can learn (hehe)

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 2, 2003, 3:40am UTC](https://forum.kirupa.com/t/timer-mx/17162/17 "2003-04-02T03:40:50Z")

</div>

yeah wrap your brain around that. The hardest part was getting the math equations right to move the dragger according to the scroll value. I will be back tomorrow so if you have any questions I’ll help then. 🙂

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 2, 2003, 7:37pm UTC](https://forum.kirupa.com/t/timer-mx/17162/18 "2003-04-02T19:37:57Z")

</div>

Ok well here are some questions, see if you can answer them. One thing I notice was, if I press the down button the scrollbar did not budge… the only way it moved was to first click on the scrollbar and then press the up and down buttons, my question is why does it do that? and second, I was wondering how was it you got it to work? I’ve been trying, but been unsuccesful ☹ OK well thx 🙂

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 2, 2003, 7:39pm UTC](https://forum.kirupa.com/t/timer-mx/17162/19 "2003-04-02T19:39:13Z")

</div>

o0o before I foger, my other question was, I want a smaller text box… I tried it, but the scrollbar stop half way, so does that mean I have to make the scroll bar the same height as the text box? or is there another way, and is it too hard?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 2, 2003, 10:38pm UTC](https://forum.kirupa.com/t/timer-mx/17162/20 "2003-04-02T22:38:58Z")

</div>

1. to fix the first problem, change this line:

```auto

dragger.onRelease = dragger.onReleaseOutside = function ()

```

to

```auto

dragger.onRelease = dragger.onReleaseOutside = dragger.onMouseDown = function ()

```

1. it should work with any size text box. It works for me when I change the size of the text box. Attach your file here and I can take a look at it, but it _ **should** _ work.

[Next page](https://forum.kirupa.com/t/timer-mx/17162.md?page=2)
