Be a Supporter!

Flash Calculator Action Script 3...

  • 778 Views
  • 9 Replies
New Topic Respond to this Topic
Jolly
Jolly
  • Member since: Jun. 6, 2008
  • Offline.
Forum Stats
Moderator
Level 43
Programmer
Flash Calculator Action Script 3... 2009-05-15 23:21:49 Reply

What's wrong with this code? I don't know why it won't work.

stop();
plus_btn.addEventListener(MouseEvent.CLICK,plusClick);
sub_btn.addEventListener(MouseEvent.CLICK,subClick);
mult_btn.addEventListener(MouseEvent.CLICK,multClick);
div_btn.addEventListener(MouseEvent.CLICK,divClick);
eqls_btn.addEventListener(MouseEvent.CLICK.equalClick);



var plusSym:Boolean = false;
var subSym:Boolean = false;
var multSym:Boolean = false;
var divSym:Boolean = false;

num1.border=false;
num2.border=false;
num1.restrict = "0-9";
num2.restrict = "0-9";

function plusClick(event:MouseEvent):void{
	plusSym = true;
	subSym = false;
	multSym = false;
	divSym = false;
	Sym_txt.text= "+";
}

function subClick(event:MouseEvent):void{
	plusSym = false;
	subSym = true;
	multSym = false;
	divSym = false;
	sym_txt.text= "-";
}

function multClick(event:MouseEvent):void{
	plusSym = false;
	subSym = false;
	multSym = true;
	divSym = false;
	sym_txt.text= "x";
}

function divClick(event:MouseEvent):void{
	plusSym = false;
	subSym = false;
	multSym = false;
	divSym = true;
	sym_txt.text = "/";
	
}



//-----------------------Numbers------------------//
var input1:String;
var input2:String;
var plusRes:Number;
var subRes:Number;
var multRes:Number;

function equClick(event:MouseEvent):void{
	input1 = num1.text;
	input2 = num2.text;
	if(plusSym == true){
		plusRes = parselnt(input1) + parselnt(input2);
		plusRes.toString()
		results_txt.text = String(plusRes);
		} else if(subSym == true){
			subRes = parselnt(input1) - parselnt(input2);
		subRes.toString()
		results_txt.text = String(subRes);
		} else if(multSym == true;){
		multRes = parselnt(input1) * parselnt(input2);
		multRes.toString()
		results_txt.text = String(multRes);
		} else if (divSym == true;) {
			divRes = parselnt(input1) / parselnt(input2);
		divRes.toString()
		results_txt.text = String(divRes);
		} else if {
			results_txt.text = "Please choose and operator.";
		}
}
The-titan
The-titan
  • Member since: Jul. 23, 2005
  • Offline.
Forum Stats
Member
Level 25
Game Developer
Response to Flash Calculator Action Script 3... 2009-05-15 23:33:03 Reply

whats does the error thing say? could be that you forgot one more '}' at the end


BBS Signature
Jolly
Jolly
  • Member since: Jun. 6, 2008
  • Offline.
Forum Stats
Moderator
Level 43
Programmer
Response to Flash Calculator Action Script 3... 2009-05-15 23:34:10 Reply

At 5/15/09 11:33 PM, The-titan wrote: whats does the error thing say? could be that you forgot one more '}' at the end

This...

Flash Calculator Action Script 3...

The-titan
The-titan
  • Member since: Jul. 23, 2005
  • Offline.
Forum Stats
Member
Level 25
Game Developer
Response to Flash Calculator Action Script 3... 2009-05-15 23:38:57 Reply

remove the ';' at the end of the statements so it would go like

} else if (multSym == true ){

BBS Signature
headphenomenon
headphenomenon
  • Member since: May. 1, 2009
  • Offline.
Forum Stats
Member
Level 13
Programmer
Response to Flash Calculator Action Script 3... 2009-05-15 23:40:30 Reply

i have the same AS [Fixed though, check it out as my first submission using BrainToast]

stop();
plus_btn.addEventListener(MouseEvent.CLICK,plusClick);
sub_btn.addEventListener(MouseEvent.CLICK,subClick);
mult_btn.addEventListener(MouseEvent.CLICK,multClick);
div_btn.addEventListener(MouseEvent.CLICK,divClick);
eqls_btn.addEventListener(MouseEvent.CLICK.equalClick);



var plusSym:Boolean = false;
var subSym:Boolean = false;
var multSym:Boolean = false;
var divSym:Boolean = false;

num1.border=false;
num2.border=false;
num1.restrict = "0-9";
num2.restrict = "0-9";

function plusClick(event:MouseEvent):void{
	plusSym = true;
	subSym = false;
	multSym = false;
	divSym = false;
	Sym_txt.text= "+";
}

function subClick(event:MouseEvent):void{
	plusSym = false;
	subSym = true;
	multSym = false;
	divSym = false;
	sym_txt.text= "-";
}

function multClick(event:MouseEvent):void{
	plusSym = false;
	subSym = false;
	multSym = true;
	divSym = false;
	sym_txt.text= "x";
}

function divClick(event:MouseEvent):void{
	plusSym = false;
	subSym = false;
	multSym = false;
	divSym = true;
	sym_txt.text = "/";
	
}



//-----------------------Numbers------------------//
var input1:String;
var input2:String;
var plusRes:Number;
var subRes:Number;
var multRes:Number;

function equClick(event:MouseEvent):void{
	input1 = num1.text;
	input2 = num2.text;
	if(plusSym == true){
		plusRes = parselnt(input1) + parselnt(input2);
		plusRes.toString()
		results_txt.text = String(plusRes);
		} else if(subSym == true){
			subRes = parselnt(input1) - parselnt(input2);
		subRes.toString()
		results_txt.text = String(subRes);
		} else if(multSym == true){
		multRes = parselnt(input1) * parselnt(input2);
		multRes.toString()
		results_txt.text = String(multRes);
		} else if (divSym == true) {
			divRes = parselnt(input1) / parselnt(input2);
		divRes.toString()
		results_txt.text = String(divRes);
		} else if {
			results_txt.text = "Please choose and operator.";
		}
}
}

06-17-11: User of the Day
07-25-11: 1500th Post
08-09-11: Level 13!

Jolly
Jolly
  • Member since: Jun. 6, 2008
  • Offline.
Forum Stats
Moderator
Level 43
Programmer
Response to Flash Calculator Action Script 3... 2009-05-15 23:43:08 Reply

At 5/15/09 11:38 PM, The-titan wrote: remove the ';' at the end of the statements so it would go like

} else if (multSym == true ){

That caused more errors...

Flash Calculator Action Script 3...

The-titan
The-titan
  • Member since: Jul. 23, 2005
  • Offline.
Forum Stats
Member
Level 25
Game Developer
Response to Flash Calculator Action Script 3... 2009-05-15 23:47:41 Reply

i find it hard to help you this way, maybe upload the fla somewhere? ill have a look and fix it for you.


BBS Signature
Jolly
Jolly
  • Member since: Jun. 6, 2008
  • Offline.
Forum Stats
Moderator
Level 43
Programmer
Response to Flash Calculator Action Script 3... 2009-05-15 23:51:47 Reply

@U-Gamer
That didn't work either for some reason...

The-titan
The-titan
  • Member since: Jul. 23, 2005
  • Offline.
Forum Stats
Member
Level 25
Game Developer
Response to Flash Calculator Action Script 3... 2009-05-16 00:18:08 Reply

sent pm with fixed fla. Next time watch out for those silly spelling mistakes. c:


BBS Signature
mongoid
mongoid
  • Member since: Jan. 3, 2002
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to Flash Calculator Action Script 3... 2009-05-16 03:59:35 Reply

We didn't create new problems. The text and variables you're modifying are either non-existent or out of scope of your code.

At 5/15/09 11:43 PM, JollySpace wrote:
At 5/15/09 11:38 PM, The-titan wrote: remove the ';' at the end of the statements so it would go like

} else if (multSym == true ){
That caused more errors...