Calculator
March 4th, 2009 Posted in Flex
Flex…Flex is a collection of technologies released by Adobe Systems for the development and deployment of cross-platform rich Internet applications based on the proprietary Adobe Flash platform. This is Flex, is the most powerful platform for the Flash, now many of you will say that you know to work in Adobe CS4 or CS3 Flash Professional and is enough. But I will come and say that Flash CS4 Professional is mostly for animations, not for creating applications, or developing any kind of things. For developing Flex is
the best way for the performance.
For the next post I prepared a very simple calculator, I will show you the code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" frameRate="30" layout="absolute" viewSourceURL="srcview/index.html"> <mx:Script> <![CDATA[ import mx.events.FlexEvent; /** * @private * We introduces variables that are specific to each operation * nr_1 is for the first number that will be introduced in the Calculator * nr_2 of course is for the second number **/ private function calculate (event:MouseEvent):void { var nr_1:Number = Number(text_1.text); var nr_2:Number = Number(text_2.text); var amount:Number; var product:Number; var division:Number; var subtract:Number; /** * Operations corresponding to each variable **/ amount = nr_1 + nr_2; product = nr_1 * nr_2; division = nr_1 / nr_2; subtract = nr_1 - nr_2; /** * Well here we show the type of operation you want to do * By selecting a RadioButton **/ if (plus.selected == true) { result.text = String(Math.floor(amount)); } else if (minus.selected == true) { result.text = String(Math.floor(subtract)); } else if(inmultire.selected == true) { result.text = String(Math.floor(product)); } else { result.text = String(Math.floor(division)); } } ]]> </mx:Script> <mx:Panel width="400" height="300" layout="absolute" title="Calculator" id="panel" left="10" top="10"> <mx:TextInput width="70" height="20" id="text_1" x="82" y="30"/> <mx:TextInput width="70" height="20" id="text_2" x="82" y="67"/> <mx:TextInput x="82" y="109" width="70" height="20"/> <mx:TextInput x="82" y="109" width="70" height="20" id="result"/> <mx:Button label="Calculate" click="calculate(event)" x="151" y="209"/> <mx:Label x="10" y="32" text="Number 1:"/> <mx:Label x="10" y="69" text="Number 2:"/> <mx:Label x="10" y="111" text="Resulte:"/> <mx:RadioButton x="295" y="25" label="+" id="plus"/> <mx:RadioButton x="295" y="50" label="-" id="minus"/> <mx:RadioButton x="295" y="75" label="*" id="inmultire"/> <mx:RadioButton x="295" y="100" label="\" id="impartire" selected="true"/> </mx:Panel> </mx:Application> |
There is the resulte: Calculator

April 7th, 2009 at 11:07 AM
Great site this blog.flashdesign-store.com and I am really pleased to see you have what I am actually looking for here and this this post is exactly what I am interested in. I shall be pleased to become a regular visitor