Home >
In LFFS - 9
, we included a "homework" assignment in the form of a non-functioning calculator with the hopes that those new to Flex may learn from attempting to get it to work. After I came up with a solution, it was code-reviewed by Adam, and a few changes were made in order to comply with best practices. We've included the source code for both, but we will be focusing our attention on the revised version as we go through an explanation of the code step by step.Let's start with the MXML. We didn't need to code the MXML, as it was provided for us, but we need to understand what it does. Right below our application declaration, we have a Style tag:
<mx:Style source="calculator.css" />
This refers to the file "calculator.css", which contains information about the look and feel of our calculator. The inclusion of the Style tag allows us to reference that .css file elsewhere in the application, as we'll soon see.
The next MXML we see is our CDATA section, which separates the ActionScript portion of the application.
<mx:Script>
<


Bug:
try: 1 + 1 * 2
the result should be 3
but result is 2
The view breaks when you add too many numbers
There is a bug... bug not in the way you describe... a calculator would calculate 1 + 1 * 2 to be 4. There would be no order of operations.
2 * 1 + 1 would be three.
This doesn't string together your calculation
Great job Beta testers!
Thanks for catching that. We'll do another post shortly with an updated version.
Cheers!