Using parentheses can deliver different results. If you get really lost, here’s a sample FLA that has all the details.Īs in algebra, multiplications and divisions are calculated before additions and subtractions, and the use of parentheses specifies that anything in the parentheses will be calculated first. The “addition” textbox will display the results of one plus one, the subtraction textbox will display the results of five minus two, etc. We then give an expression to which "addition” is equal. Remember the Variable names we gave to the four textboxes? The first line starts with “addition”. There are four lines, and at the beginning of each is a Variable reference. Now, an explanation of what this code does and why. Choose Expert Mode from the Actions panel pop-up menu (at the upper right of the panel). In order to give ourselves freedom to type what we wish, we need to set the Actions panel to Expert Mode. Select the first frame in your Actions layer. We do this so that we can easily see which layer contains the code, and which layer contains the user interface. Name the layer containing the textboxes “Calculations”, and name the new layer “Actions”. We’ll be using these variables to tell Flash were to display the results of our calculations. This would be like having two brothers named John and John, and having you mom say, "Tell John to wash the car and tell John to clean the bathroom.” Avoid the confusion by giving every object a unique name. Otherwise, you run the risk of confusing Flash. Tip: When developing, you should always give objects (textboxes, components, Movieclips, etc.) unique names. In this example, I’m using “addition”, “subtraction”, “multiplication”, and “division” as the Variable names. Once that’s done, give each textbox a Variable name.The dynamic property is set on the Properties panel. Draw four dynamic textboxes on your stage.Start up Flash, and create a new movie.By “static”, I mean equations that are hard coded, and do not require any input from the end user.Īll these calculations are performed with ActionScript, so we’ll be doing a little coding. To get you acquainted with what Flash can do, we’ll start off with simple, static calculations. This tutorial is the first attempt to pique developer awareness of, and interest in, Flash’s math capabilities.įlash can handle any equation you throw at it, from simple addition, to complex calculus. If Rich Internet Applications are going to be as big as Macromedia hopes, more tutorials and examples covering basic, real-world business needs like calculating data will need to be written. Sure, there are plenty of examples the explain the use of math to make random swirling lines, flying squares, and dancing midgets, but what about using math to calculate data? Those dancing midgets are cute, but calculating data can make money.Īfter looking through about 30 books, I found two that offered about a page on what I was looking for. Go to your local bookstore, look at any book claiming to be the be-all and end-all and for Flash, and see what you can find under “math” or “equations”. I then went to my local bookstore in search of answers, but found the same problem: there is virtually no documentation available on using math in real world Flash applications.ĭon’t believe me? Search on for the term “calculation”. Unfortunately, I found very little information on what I was looking for. So, like any good Web user, I started to search forums and Google for some guidance. I knew that calculations were possible in Flash it was just that I’d never done any. The Search for Information on Flash’s Calculation AbilitiesĪ little over a year ago, I started a project that required Flash to do some serious calculations. We’ll also cover the capture of data input by a user, and learn how to perform calculations based on this data. In this tutorial, we will cover how to do basic arithmetic in Flash. One of the basic requirements of any business app is the ability to do math. Along with the funny cartoons, Flash can now be used to build business applications. Macromedia has spent an enormous amount of money and effort to bring Flash out of its “animation only” box, and promote it as a cross-platform development environment, as well as a designer environment. The days of Flash being used solely for entertainment are over.
0 Comments
Leave a Reply. |