LiveWire Peer Support Network

Printable Version of Topic "AS 3.0 Problem"

- LiveWire Teen Forums & College Forums (http://www.golivewire.com)
-- (http://www.golivewire.com/forums/support-technical.html)
--- General Tech Discussion (http://www.golivewire.com/forums/forum-210-s-0.html)
---- AS 3.0 Problem (http://www.golivewire.com/forums/peer-yesneit-support-a.html)


-- Posted by Randomaster at 9:42 pm on Jan. 5, 2009

I'm making a calculator in Flash CS3 using actionscript 3.0.

It has the Multiply, Divide, Plus & Minus buttons.
When i input the code for one button, that button works, but when i input the code for more than one, none of the buttons work.
What am I doing wrong?

Download Calculate.fla

Code:
MinusButton_btn.addEventListener(MouseEvent.CLICK, doMyCalculation);

function doMyCalculation(e:MouseEvent):void
{
   var total : Number;

   // PROCESS
   total = Number(N1.text)-Number(N2.text);

   // OUTPUT
   total.text = String(myAnswer);
};

MultiplyButton_btn.addEventListener(MouseEvent.CLICK, doMyCalculation);
{
   var total : Number;

   // PROCESS
   total = Number(N1.text)*Number(N2.text);

   // OUTPUT
   total.text = String(myAnswer);
};

DivideButton_btn.addEventListener(MouseEvent.CLICK, doMyCalculation);
{
   var total : Number;

   // PROCESS
   total = Number(N1.text)/Number(N2.text);

   // OUTPUT
   total.text = String(myAnswer);
};

PlusButton_btn.addEventListener(MouseEvent.CLICK, doMyCalculation);
{
   var total : Number;

   // PROCESS
   total = Number(N1.text)+Number(N2.text);

   // OUTPUT
   total.text = String(myAnswer);
}

Thanks guys  


-- Posted by Randomaster at 9:44 pm on Jan. 5, 2009

Quote: from oridniv at 3:44 pm on Jan. 6, 2009


good for u...can you make a graphing one like the TI80s series
thanks for the help  


-- Posted by TBMP at 9:44 pm on Jan. 5, 2009

i think it has to do with the placement of your //OUTPUT

i'm just an amateur at coding though


-- Posted by 4est at 9:45 pm on Jan. 5, 2009

Are you sure that '*' is an acceptable character for use in flash? I'm no programming expert, but I know flash is very picky about things like that.


-- Posted by ObviousObscurity at 9:47 pm on Jan. 5, 2009

I don't do flash, but
[this got a little tangled in my head, to be honest..]


why'd you copy and paste the code again? It looks like it should just be
MultiplyButton_btn.addEventListener(MouseEvent.CLICK, doMyCalculation);
DivideButton_btn.addEventListener(MouseEvent.CLICK, doMyCalculation);

etc? That's my closest guess. the documentation seems to show that function being used that way.


-- Posted by Randomaster at 9:50 pm on Jan. 5, 2009

Quote: from 4est at 3:45 pm on Jan. 6, 2009


Are you sure that '*' is an acceptable character for use in flash? I'm no programming expert, but I know flash is very picky about things like that.
Yes, "*" is the universal symbol for multiplication in computing.


www.golivewire.com