View Full Version : I am new
zexxuazi
09-28-2004, 02:58 AM
I am trying out flash and I want to dafine a function and use it. Can somebody tell me how to do it? Its a very simple function:
function multiply (a,b,c) {
return c = a*b;
}
so this is the function.
I have three text fields. 2 inputs and 1 dyn. I want the two values of the two inputs to be multiplied and the result to be displayed in the third one.
Thanx.
mmm..pi..3.14..
09-28-2004, 04:22 AM
Try this...
Eric
zexxuazi
10-01-2004, 02:09 AM
Thanx for the Reply.
Another Prob:
rest.onRelease = function (a,b) {
if (a = "", b = "") {
gotoAndStop ("Scene 1", 2);
} else {
multiply();
};
};
a and b are textfields. It doesn't work. Whats wrong?
Thanx
mmm..pi..3.14..
10-01-2004, 02:12 AM
it needs to be a.text = "", b.text = "", otherwise flash thinks it's a variable
zexxuazi
10-01-2004, 02:16 AM
tried that,
doesn't work,
thanks.
mmm..pi..3.14..
10-01-2004, 02:18 AM
Oh...stupid me, forgot to tell you that "=" will set a variable to something, to test for something you have to do "==", so it should look like:
a.text == "", b.text == ""...
Eric
zexxuazi
10-01-2004, 02:21 AM
tried that too.
Ok. Heres what I am trying to do: (I know this is real priliminary 4 u but... I am a total beginner)
stop();
textField._a.maxChars = 5;
textField._b.maxChars = 5;
function multiply() {
c.text = a.text*b.text;
};
rest.onRelease = function (a,b) {
if (a.text == "", b.text == "") {
gotoAndStop ("Scene 1", 2);
} else {
multiply();
};
};
cl.onRelease = function() {
a.text = "";
b.text = "";
c.text = "";
};
zexxuazi
10-01-2004, 02:22 AM
rest and cl are button instances
mmm..pi..3.14..
10-01-2004, 02:22 AM
Why do you have "function(a, b)", I don't hink you need that, try it with just function()
Eric
zexxuazi
10-01-2004, 02:23 AM
worked,
thanks!
mmm..pi..3.14..
10-01-2004, 02:24 AM
I always get alot of errors and trouble when adding parameters so I just decide to leave them out unless absolutely necessary.
mmm..pi..3.14..
10-01-2004, 02:24 AM
:D Glad to help
Eric
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.