Flash Games

 FAQ   Search   Members   Groups   User Control Panel      Login 

It is currently Fri Dec 05, 2008 1:59 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Multiplying variables...
PostPosted: Wed Feb 27, 2008 10:44 pm 
Offline

Joined: Wed Feb 27, 2008 10:34 pm
Posts: 2
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();


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 03, 2008 12:13 am 
Offline
User avatar

Joined: Tue Jul 11, 2006 1:56 am
Posts: 35
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.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 03, 2008 12:22 am 
Offline

Joined: Wed Feb 27, 2008 10:34 pm
Posts: 2
Hi Solar!

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

Best regards,
Gerry


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group - Flash Games

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: