7 Replies Latest reply on Oct 15, 2009 9:48 AM by PeakDigital

    Ubber Newbie Looking for Basic Samples

    mushman Level 1

      Hello- I've spent the last 3 hours or so trying to create a very basic calculator in Flex (aka: add a couple input cells). Spent time looking through videos, reading documentation, etc. Much of it assumes programming background or web development experience of which I have little.

       

      So, wanted to find some very basic application samples I could take apart and learn from. I found some, but they are pretty advanced and most depend on communication to/from the internet (tons of facebook and photo apps).

       

      I'm just looking for a simple calculator/mortgage calculator application I can take apart and learn from.

       

      Anyone know where I can find examples for super basic users?

       

      Thanks!

      - Mr. Bill

        • 1. Re: Ubber Newbie Looking for Basic Samples
          RedOctober57

          Hi Bill.  I have the same problem as you.. learning ActionScript mixed with mxml, mixed with ColdFusion's cfml, etc etc..  is a daunting task.  I've got extensive programming experience but with 3GL.  I'm still struggling with the learning even the most basic operations.

           

          Swanyway... maybe you've seen these but just in case you haven't...

           

          http://help.adobe.com/en_US/Flex/4.0/html/WSbde04e3d3e6474c46307b4041210cbec9c9-8000.html

           

          http://cookbooks.adobe.com/tags/Flex%2Cflex+and+other+technologies

           

          Seems like the helps, help people who already "know" but just need a "reminder".

           

          The videos are great though!  Without those, I would have given up on FlashBuilder and ColdFusion a long time ago.

          • 2. Re: Ubber Newbie Looking for Basic Samples
            mushman Level 1

            Hey RedOctober- Thanks for the response and help.

             

            Looked at the resources and they look good.... but way over my head. Funny enough, All I'm trying to do it X+Y=Z. I guess its so basic, Adobe assumes people already know how to do this.

             

            Thanks Again!

            • 3. Re: Ubber Newbie Looking for Basic Samples
              PeakDigital Level 1

              Here is an extremely basic example of one way it can be done. You of course would need more operators, conditional code to handle those operators, and several other functions and formulas - especially for mortgages - but hopefully this will get you started on the basic method.

               

              <?xml version="1.0" encoding="utf-8"?>
              <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" height="208" width="444">
                 <mx:Script>
                   <![CDATA[
                   private function BasicCalc():void
                   {
                   var CalculatedValue:Number=Number(TextInput1.text) + Number(TextInput2.text);
                   ResultText.text=String(CalculatedValue);     
                   }
                   ]]>
                   </mx:Script>
                  <mx:TextInput id="TextInput1" x="24" y="41" width="50" textAlign="right" text="1"/>
                  <mx:TextInput id="TextInput2"  x="24" y="71" width="50" textAlign="right" text="2"/>
                  <mx:Text id="ResultText" x="44" y="101" text="0" width="30" textAlign="right"/>
                  <mx:Button id="CalcButton" x="82" y="41" label="Calc" width="57" height="52"  click="BasicCalc()"/>
                  
              </mx:Application>
              
              • 4. Re: Ubber Newbie Looking for Basic Samples
                mushman Level 1

                Hello- Thanks for the idea.

                 

                If I just want to add two input cells (input1 and input2), I'd have to write all that code?

                 

                Thanks!

                 

                (told you it was ubber basic )

                • 5. Re: Ubber Newbie Looking for Basic Samples
                  PeakDigital Level 1

                  Are you using Flex Builder, or just the free Flex SDK and hand-coding everything?  If you're using Flex Builder, most of that is done for you, and the input controls can be defined (written) with drag and drop of controls onto the application design pane. All that has to be manually written is the calculation function code.

                  • 6. Re: Ubber Newbie Looking for Basic Samples
                    mushman Level 1

                    Thanks for the help. I'm using flexbuilder. Building the interface was a breeze. I just can't find the the correct calculation code. Looked through the actionscript reference manual and all other guides without luck. I feel really stupid because all I'm trying to do is add two input cells and have it appear in another text cell.

                     

                    Thanks for helping out!

                    • 7. Re: Ubber Newbie Looking for Basic Samples
                      PeakDigital Level 1

                      The BasicCalc() function in my first post should be all you need for adding 2 input cells and displaying the result in another control (rename the controls to whatever IDs you are using, of course)

                       

                      var CalculatedValue:Number=Number(TextInput1.text) + Number(TextInput2.text);
                      ResultText.text=String(CalculatedValue);

                       

                      Have you researched the Math class in the reference? http://livedocs.adobe.com/flex/3/langref/Math.html