Flash Games
 FAQ   Search   Memberlist   Usergroups   Register  Profile   Log in to check your private messages   Log in 


Multiplying variables...



 

Post new topic   Reply to topic  
   DEVPPL Forum Index -> Flash Forum
View previous topic :: View next topic  
Author Message
Germaris



Joined: 27 Feb 2008
Posts: 2

PostPosted: Wed Feb 27, 2008 10:44 pm    Post subject: Multiplying variables... Reply with quote

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:
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();
Back to top
View user's profile Send private message
Solar42693



Joined: 11 Jul 2006
Posts: 35

PostPosted: Mon Mar 03, 2008 12:13 am    Post subject: Re: Multiplying variables... Reply with quote

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:

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.
Back to top
View user's profile Send private message
Germaris



Joined: 27 Feb 2008
Posts: 2

PostPosted: Mon Mar 03, 2008 12:22 am    Post subject: Re: Multiplying variables... Reply with quote

Hi Solar!

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

Best regards,
Gerry
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    DEVPPL Forum Index -> Flash Forum All times are GMT + 1 Hour
Page 1 of 1

 
 
Welcome to DEVPPL.com
You are not logged in, which means that you can't post in the forums.
Click here to Register

If you are a current member here on DEVPPL, please login below:

User: Pass:
Log me on automatically each visit:

 


Powered by phpBB © 2001, 2005 phpBB Group - Modified by DEVPPL

Flash Games - Sitemap