LiveWire Network Peer Answers Peer Support Teen Forums Tech Forums College Forums 337 users online 223222 members 295 active today Advertise Here Sign In
TeenCollegeTechPhotos | Quizzes | LiveSecret | Memberlist | Dictionary | News | FAQ
Member Spotlight
Im the Dude
LiveWire's Executive Chef I'm Manny Pacquiao's bitc...
Mood: Sleepy
You have 1 new message.
Emergency Help
Until you sign up you can't do much. Yes, it's free.

Sign Up Now
Membername:
Password:
Already have an account?
Invite Friends
Active Members
Groups
Contests
Moderators
5 online / 10 MPM
Fresh Topics
  LiveWire / Technical Forums / General Tech Discussion / Adding Reply

Quoting Post
Archived Topic: It will not be bumped to the top of the forum.
Topic AS 3.0 Problem
Membername   Not a member? Sign Up Free (takes 20 seconds)
Password   Forgotten your password?
Post

Font:   Size:   Color:

FAQ Keyword Search:
Post Options
Favorites Manager
Notify me of new replies to this topic by email
Notify me of new replies to this topic by private message
Original Post
Randomaster Posted 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  

Replies
Randomaster Posted 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.
ObviousObscurity Posted 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.

4est Posted 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.
TBMP Posted 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

Dass Posted at 9:44 pm on Jan. 5, 2009
Post from this position was omitted due to content violations
Randomaster Posted 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  
Doghouse Posted at 9:44 pm on Jan. 5, 2009
Post from this position was omitted due to content violations
JimCarryFan Posted at 9:44 pm on Jan. 5, 2009
Post from this position was omitted due to content violations
oridniv Posted at 9:44 pm on Jan. 5, 2009
Post from this position was omitted due to content violations
Joke Posted at 9:43 pm on Jan. 5, 2009
Post from this position was omitted due to content violations
All 10 previous replies displayed.