Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 04-14-2012, 11:50 AM   #1
mafffs
Registered User
 
Join Date: Apr 2012
Posts: 2
Default Updating dynamic text field problem

Hello!

Im having some problems updating a dynamic text field via a button. I want to make number field that you can either increase or decrease with two buttons.

Somehow the variable I assign to textFieldName.text won't show up in the field when I click the button? The update works but the updated text don't show up in the field?

here's my code:

Code:
on(press) {
	if (gCount == undefined) {
		var gCount:Number = 0;
		gCounter.text = gCount;
	}
	else if (gCount > 10) {
		trace('Bigger than 10');
	}
	else {
		gCount = ++gCount;
		gCounter.text = gCount;
		trace('G counter = ' + gCounter.text);
	}
}
I've tried formatting the gCount to a string without success.

Anyone have any solution? That would be great.

If you have suggestions on how to solve the problem on some other way that would be nice as well!

Last edited by mafffs; 04-14-2012 at 04:09 PM.
mafffs is offline   Reply With Quote
Old 04-14-2012, 10:44 PM   #2
Prid
Prid - Outing
 
Prid's Avatar
 
Join Date: Oct 2009
Location: Halden, Norway
Posts: 1,191
Send a message via MSN to Prid Send a message via Skype™ to Prid
Default

Code:
gCount = ++gCount;
Where do people get that from, it's the other way around, lolz :P

Code:
gCount = gCount++;
and you should not convert your gCount variable to a String, otherwise the variable will not have its Math functionality, unlike a Number variable:

ActionScript Code:
gCount:Number = 1; gCount += 2; trace(gCount); // 3

ActionScript Code:
gCount:String = 1; gCount += 2; trace(gCount); // 12
__________________
I have returned, and am now 18
Prid is offline   Reply With Quote
Old 04-15-2012, 09:37 AM   #3
mafffs
Registered User
 
Join Date: Apr 2012
Posts: 2
Default

Thanks! I'm new to action script and got it from some online example. In fact gCount++ doesn't work at all...

The counting works as well. The problem is that the dynamic field doesn't show the gCount variable. When I press the button the field becomes blank.

Any suggestion why this is?

Last edited by mafffs; 04-15-2012 at 09:45 AM.
mafffs is offline   Reply With Quote
Old 04-15-2012, 01:12 PM   #4
tacos
Grrrrrrrrreat!
 
tacos's Avatar
 
Join Date: Apr 2007
Location: Montréal, Québec
Posts: 5,473
Default

@Prid...

ActionScript Code:
var count:Number = 0; count = ++count; trace(count); // traces 1
__________________
WHO I WAS...
BANDS OF THE 80's
tacos is offline   Reply With Quote
Old 04-15-2012, 01:16 PM   #5
tacos
Grrrrrrrrreat!
 
tacos's Avatar
 
Join Date: Apr 2007
Location: Montréal, Québec
Posts: 5,473
Default

Is the Var box in the gCounter's properties clear as it should, or have you inserted gcount there also?
__________________
WHO I WAS...
BANDS OF THE 80's
tacos is offline   Reply With Quote
Old 04-15-2012, 02:14 PM   #6
Prid
Prid - Outing
 
Prid's Avatar
 
Join Date: Oct 2009
Location: Halden, Norway
Posts: 1,191
Send a message via MSN to Prid Send a message via Skype™ to Prid
Default

Oh, it really works, didn't know, but an easier way to increment a variable is this way, just that:

Code:
gCount++;
as for your problem, wanna post your FLA file?

Use TinyUpload to upload your FLA file, and post the link here WITHOUT http://www.
__________________
I have returned, and am now 18
Prid 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 06:46 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.