You are here: DEVPPL Forum Programming Flash Forum
NOTIFICATIONS
54.087
MEMBERS
15.684
TOPICS
62.255
POSTS
  562
FLASH GAMES
7.740
TUTORIALS
 

Login

E-mail:
Password:

Multiplying variables...

0

Loading

Multiplying variables...

Postby Germaris » Wed Feb 27, 2008 10:44 pm

Hi there!

Here is the whole script of a test document which doesn't work...
Excuse me but I never used multiplication of variables and I confess how shameful I feel.
I absolutely don't understand the explanations the Flash Help contains...

Document contains three Input Fields, a Dynamic Field and a Button.
Clicking the Button returns NaN !!!

I thank you in advance for any help.

Best regards from Old Gerry


Code: Select all
var a:Number = new Number(field1.text);
var b:Number = new Number(field2.text);
var c:Number = new Number(field3.text);
operationFct = function () {
   var res:Number = new Number();
   res = (a * b) + c;
   resultFld.text = res;
};
myButton.onRelease = function() {
   operationFct();
};
stop();
Germaris
 
Reputation: 0
Posts: 2
Joined: Wed Feb 27, 2008 10:34 pm
Highscores: 0
Arcade winning challenges: 0

Multiplying variables... - Sponsored results

Sponsored results

Login to get rid of ads

 

0

Loading

Postby Solar » Mon Mar 03, 2008 12:13 am

The problem isn't your multiplication. When you defined var a-c, it was when the frame loaded. At that point, there was nothing in them. You need to redefine your variables in the function like this:

Code: Select all
operationFct = function () {
   var a:Number = new Number(field1.text);
   var b:Number = new Number(field2.text);
   var c:Number = new Number(field3.text);
   var res:Number = new Number();
   res = (a*b)+c;
   resultFld.text = res;
};
myButton.onRelease = function() {
   operationFct();
};
stop();


Although if you leave the input textfields empty you would still get NaN.
Solar
 
Reputation: 0
Posts: 35
Joined: Tue Jul 11, 2006 1:56 am
Highscores: 0
Arcade winning challenges: 0
0

Loading

Postby Germaris » Mon Mar 03, 2008 12:22 am

Hi Solar!

Thanks for replying!
Silly of me... You are right!
Good tip.

Best regards,
Gerry
Germaris
 
Reputation: 0
Posts: 2
Joined: Wed Feb 27, 2008 10:34 pm
Highscores: 0
Arcade winning challenges: 0
^ Back to Top