Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 08-28-2004, 02:56 PM   #1
irvinesteven
Registered User
 
Join Date: Aug 2004
Posts: 6
Post Decreasing Text Counter

Hey Everyone,

I need to create a text input box that has a counter above it that counts down from 160 to 0 (each character typed decreases the value by 1), on reaching zero the counter resets itself again and continues to decrese but displays a (2) next to it, informing the user that they are now on their second set of characters. E.g it would start as 160(1) then display 160(2), then 160(3) etc... much like the text message function on a Nokia Phone.

Any help with this would be much appreciated. And I thank in advance anyone that can work this out for me.

Thanks again..

SDI
irvinesteven is offline   Reply With Quote
Old 08-28-2004, 08:48 PM   #2
wu-tang
Senior Member
 
Join Date: Jan 2004
Posts: 279
Default

Here is a file with the an example of how to structure it. You will need to change the math a bit to go beyond 160 (2).

http://www.justintense.com/transfer/test.fla
wu-tang is offline   Reply With Quote
Old 08-29-2004, 11:57 AM   #3
irvinesteven
Registered User
 
Join Date: Aug 2004
Posts: 6
Default Thanks man..but...

Hey Wu-Tang you are a genius thanks man..

I owe you one. Just a quick question though being a bit of a novice to actionscript, what would be the best way to decrease the text fropm 160 to 0 instead of 0 to 160 like you have coded.

thanks again

irvinesteven
irvinesteven is offline   Reply With Quote
Old 08-29-2004, 07:57 PM   #4
wu-tang
Senior Member
 
Join Date: Jan 2004
Posts: 279
Default

no sweat my man. too decrease just change the math a bit... I think this bit of code should exactly what you want.

Code:
var count = 1;
var total = 160;

myField.addListener();

myField.onChanged = function(){
	
	if(this.length >= this.curr) 
	{
		var chars = (total * count) - this.length;
		//trace("increase");
	}
	else if(this.length <= this.curr)
	{
		 var chars = (this.length - (total * count)) * -1;
		 //trace("decrease");
	}
	
	amount.text = chars + " (" + count +")";
	
	if(chars == 0) count ++;
	if(chars == 160) count --;
	
	this.curr = this.length;
	
}

Last edited by wu-tang; 08-29-2004 at 08:11 PM.
wu-tang is offline   Reply With Quote
Old 08-29-2004, 08:07 PM   #5
irvinesteven
Registered User
 
Join Date: Aug 2004
Posts: 6
Default A heros welcome

Cheers dude, need to pull my finger out and get learning I think.

thanks again

SDI
irvinesteven is offline   Reply With Quote
Old 08-29-2004, 08:12 PM   #6
wu-tang
Senior Member
 
Join Date: Jan 2004
Posts: 279
Default

I just updated the code a bit so make sure you grab a copy again.
wu-tang is offline   Reply With Quote
Old 08-29-2004, 08:37 PM   #7
irvinesteven
Registered User
 
Join Date: Aug 2004
Posts: 6
Default

your a legend... Thanks

SDI
irvinesteven is offline   Reply With Quote
Old 08-29-2004, 08:40 PM   #8
irvinesteven
Registered User
 
Join Date: Aug 2004
Posts: 6
Default

Wu Tang,

can you recommend a good resource guide to learning advanced actionscript. Have been using flash for a few years but concentrated on design side rather than serious coding.

cheers in advance

SDI
irvinesteven is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:29 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.