Go Back   CodingForums.com > :: Client side development > Flash & ActionScript > Adobe Flex

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-28-2009, 04:59 PM   PM User | #1
loki421
Regular Coder

 
Join Date: Feb 2009
Location: Worcester
Posts: 172
Thanks: 13
Thanked 6 Times in 6 Posts
loki421 is an unknown quantity at this point
Flex calculator??

Hi all,

I've been playing with a little app today, i came accross a simple tip calculator here http://blog.flexexamples.com/2007/09...lator-in-flex/ and thought i'd have a go at building my own calculator.

What i've got is a radiobutton group that selects either "one" or "two", then a text input (which i'm struggling to convert to numbers, something to do with parseFloat i think), and a button to calculate. Basically i'm interested in what components can be used to preform calculations.

Here's the code so far:
Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">

<mx:Script>
	<![CDATA[
		
		private function getTotal():void
		{
			total.text = <!--- radioGroup selection or value, +/-/* etc whatever the user types in the textinput --->
		}
		
	]]>
</mx:Script>



	<mx:RadioButtonGroup id="radioGroup"/>
	<mx:RadioButton label="1 - 4" groupName="radioGroup" value="one"/>
	<mx:RadioButton label="5 - 8" groupName="radioGroup" value="two"/>
        <mx:TextInput id="input"/>
	<mx:TextInput id="total"/>
	<mx:Button label="Button" click="getTotal();"/>
	
</mx:Application>
So that's basically just the components ready for the logic, but i'm really stumped now as to where to go with this.

Would anybody like to help with this?

Any pointers or links to tutorials would be gratefully recieved as always

Looking forward to your ideas all!!!!

Last edited by loki421; 04-28-2009 at 05:03 PM..
loki421 is offline   Reply With Quote
Old 04-28-2009, 05:57 PM   PM User | #2
loki421
Regular Coder

 
Join Date: Feb 2009
Location: Worcester
Posts: 172
Thanks: 13
Thanked 6 Times in 6 Posts
loki421 is an unknown quantity at this point
Ha! Check me out.... i've manged to work it out all on my tod lol

Here's the solution for anyone else who wants to have a play

Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">

<mx:Script>
	<![CDATA[
		
		private function getTotal():void
		{
			var myInt:int = parseInt(input.text);
			var myFloat:Number = parseFloat(input.text);
			var myNumber:Number = new Number(input.text);

			total.data = (myNumber - 1) + (radioGroup.selectedValue);
		}
		
	]]>
</mx:Script>



	<mx:RadioButtonGroup id="radioGroup"/>
	<mx:RadioButton label="1 - 4" groupName="radioGroup" value="3.50"/>
	<mx:RadioButton label="5 - 8" groupName="radioGroup" value="5.25"/>
	<mx:TextInput id="input" restrict="0-9" />
	<mx:TextInput id="total"/>
	<mx:Button label="Button" click="getTotal();"/>
	
</mx:Application>
Hope this helps someone
loki421 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:18 AM.


Advertisement
Log in to turn off these ads.