Actionscript 3 :: Math Inconsistencies - Build A Calculator In Flex?

Feb 6, 2010

I'm trying to build a calculator in Flex / actionscript 3 but have some weird results using the class Math :

trace(1.4 - .4); //should be 1 but it is 0.9999999999999999
trace(1.5 - .5); //should be 1 and it is 1
trace(1.444 - .444); //should be 1 and it is 1
trace(1.555 - .555); //should be 1 but it is 0.9999999999999999

I know there are some issues with floating point numbers, but as you can see, it should at least fail for all of my examples, am I right?How the problem is solved in other calculators and how should I proceed in order to build a usable calculator in Actionscript 3 .

View 3 Replies


Similar Posts:


ActionScript 3.0 :: Build A Basic Calculator In Flex?

Apr 4, 2011

I want to build a basic calculator in Flex, My calculator will do the process that is entered in the text box and it will show it on that text box.For an example :

Text Box = "10+1"
Click the button
Text Box = "11"

View 3 Replies

Flash :: Flex - TFS Build 2010 Call An Ant Script And / Or Build?

Mar 31, 2011

In TFS 2010 build, I have a new build and I want to call an ant script that builds Flash. How do I call the ant script? Also How can I compile the Flash directly? I've seen the Power Tools and this question but it doesn't help me as we don't have TFS 2008. I can't find any documentation on how to use the power tools except the 1 sentence on the bottom of download page saying to create your build the old way and import it (which isn't very helpful). I've installed the power tools on the agent computer but I don't see any new options in the Toolbox when I'm designing the build flow.

View 2 Replies

Flex :: Creating Ant Build Script To Build Only When A Dependency Was Updated?

Apr 14, 2011

I just started working with ant a few days ago. Right now I have a general buildall.xml which should call each project's build.xml. Because some projects depend on each other, I need to rebuild some other projects which depend on it. This isn't a problem--I'm just setting the depends property of the target. However, ant is always building the dependencies, even when the files haven't changed.Let's say project1 has no dependencies; project2 depends on project1; project3 depends on project1, 2; project4 depends on project1, 2, and 3; and so on.I could hack a solution which looks at project K, and checks if project 1 .. project K have updated files using uptodate. If so, then run the target. This is messy and appears unnecessary.

What is the cleanest way to implement this?EDIT: So I decided to just hack in a bunch of targets, "check_projectK" where it does the uptodate checks on all of its source files, its build file, and the build files of the 1 .. K-1 projects. Due to dependencies, this is always handled correctly. However, this is still a large amount of copy and paste for a large workspace.

View 1 Replies

Php :: Flash Integration Inconsistencies?

Jul 1, 2010

I am having some consistency problems with my flash application, when I echo out variables for flash to get, it doesn't always pick up what PHP is sending, it seems to vary from PC to PC.I am getting info from a database, and I need to pass it to flash, say for instance I need to send through 5 variables $uid,$name,$points,$from,$page , how could I go about sending these from PHP to flash using AMFPHP?

View 2 Replies

ActionScript 3.0 :: Text Formatting Inconsistencies?

Apr 14, 2010

Does anyone have any clue why the formatting of the contents of a .txt file dumped into a TextField would differ when the same file is loaded locally (during testing) versus remotely (when the project is deployed on a server)?The .txt file has simple HTML formatting that is set by a stylesheet (creating 100% in Flash, so it's not a stylesheet issue), but the paragraph breaks are much bigger when viewed online versus when tested locally.

View 4 Replies

ActionScript 3.0 :: PrintJob And Dynamic Text Inconsistencies

May 13, 2009

I have a set of dynamic textfields created and loaded with text at runtime. When I go to print them they print OK but on close inspection you can see that the printed version has words dropping down a line compared to the version on the screen!

I have tried different align settings for the text, system fonts and embedded fonts, cacheAsBitmap the textfields, printAsBitmap=true option, all to no effect.

The only thing that has worked is by drawing the texfields to a bitmapdata and printing that instead. This produces an exact copy of the screen version but the printed quality is very bad and unacceptable.

I'm pretty sure its not a procedural error in my code as the bitmapdata version is made in the same flow. So could it be a quirk in Textfield or TextFormat, or a quirk in PrintJob?

View 1 Replies

Actionscript 3 :: Flash CS5 Font Inconsistencies Across Windows/OSX?

Mar 22, 2012

We have multiple people working on a single project (and often even a single FLA), everyone's using Flash CS5.5 but some users are running Windows whilst others OSX. I've noticed that some Fonts appear differently when moving a FLA from OSX to Windows or vice versa. In particular, the vertical gutter will often be larger on Windows and sometimes even the leading will be significantly increased.

Published SWFs appear fine across both systems, it's only when you edit an unpublished FLA in the IDE or re-publish it that you notice the difference. I'll also add that this doesn't occur across all fonts and as far as I'm aware, I've only noticed it on the OTF file type (the Helvetica Neue LT family is one such example). And of course, all users have installed the same version of the font.

The problem exists regardless of whether the TextField has been added to the editor or programatically. TLF TextFields don't appear to exhibit this problem, however, we already have an extensive library built up that utilises the old TextField class so migrating to TLF isn't preferable.

This is incredibly frustrating as files move back and forth frequently and it basically boils down to telling users of one OS to ignore the alignment issues because they won't exist when published from the other system. Does anyone have any theories as to why this could be happening or how to get around it?

View 1 Replies

ActionScript 3 :: Flash - Math.floor Acting Like Math.round?

Mar 7, 2011

Here is the problem:

var p:int = 0;
var n:Number = 0;
n = 32.999999999999999;
p = Math.floor(n);
trace(p); // returns 33
n = 32.11111111111111;
p = Math.floor(n);
trace(p); // returns 32

I would expect both of these to return 32. I have searched, and it seems this is an unreported bug in AS3. Or ... am I doing something wrong?

View 4 Replies

ActionScript 2.0 :: What Is The Diffrence Between Math.floor And Math.round

Sep 26, 2005

Wat is the diffrence between these two?

View 2 Replies

ActionScript 2.0 :: [F8] Math.round And Math.ceil?

Feb 16, 2009

I have a code in which I have to use Math.round if a certain value is for example 3.67 (67 is higher than 50) and Math.ceil if a value is for example 3.23 (23 is lower than 50). What can I do to make flash calculate if what after the dot �.� in 3.23 (for example) is higher than 50?

View 2 Replies

Flex :: Actionscript 3 - How To Use Math Mod Function

Aug 25, 2011

How to use math mod function in flex?

calculate like this 7 mod(%) 2 = 1

View 1 Replies

Flex :: Math - Rotate Point From A Given Center?

Jan 30, 2012

I'm trying to rotate a point in my Canvas from a given point (center). In my MouseDown handler, I save the point where user click (oldPos), and in my MouseMove handler, I'm doing this:

private function onMouseMove(event:MouseEvent):void
{
// Where the user pointer right now

[code]......

View 1 Replies

Flex :: Math-related - Constructing Equilateral Triangle

Jan 6, 2010

I am trying to construct an equilateral triangle with the following code, but I am not seeing what I would expect to. I would expect to see a triangle drawn to the stage, but I don't see one. I think there must be something wrong in terms of the location of the tri sprite on the screen.

[Code]...

UPDATE: I can now see the triangle but it is not filled in. It seems to have the generally-correct shape, but I would expect for it be 3 sided, rather than 4.

View 3 Replies

Flex :: Math - Video Player - How Many Times It Has Played

Aug 24, 2010

I have a video player in flex which constantly plays a movie. Is there a way to see how many times it has played? So each time the movie is played, text filled populates with +1.

View 1 Replies

Flex :: Adding Runtime-library-path To Flex Build Configuration Using Ant Mxmlc Task

Feb 9, 2011

I'm trying to build a flex project, linking it to some RLSs. When setting up the project in Flex Builder, the corresponding "build configuration" (that I got by adding -dump-config to the compiler options) generates (among other things) a tag like this :

<runtime-shared-libraries>
<url>some-lib.swf</url>
<url>some-other-lib.swf</url>

[Code]....

View 2 Replies

Flex :: Build Flex Stack Bar Chart From Objects Array?

Apr 21, 2010

I have a dynamic ArrayCollection that will contain a unknown number of objects of type MyObj:

class MyObj
{
type:String

[code]........

View 1 Replies

Flex :: Return Multiple Variables From Math-crunching AS3 Function?

Nov 9, 2011

I'm new to Actionscript programming. I'm trying to figure out what is the best way to return multiple variables, each having a different data type, from a function. For example, if a function needs to return variable aa ( a string) and variable bb (a number).

The function I'm using just crunches a lot of math, and doesn't relate to an object in a GUI. One method I got from a Google search used an Object, but as (I think) this requires me to create a class, I wondered if there was a simpler way. Since an array can hold elements of different data types, perhaps this is a simpler approach (?). [code]...

View 2 Replies

Eclipse :: Retrieve Build Information After Build Completes In FDT?

Jul 30, 2011

Using FDT, when I have a debug configuration with several operations in the launcher chain and the final launcher opens in Flash Player, how can I retrieve the build output from the console once the build is complete and Flash player is running?

It seems that once Flash Player has started the console clears to make way for the application's trace output, but I need to be able to look back over the events and build times for each item in my launch chain while Flash Player is running. Is there a setting I can enable to either log my build output to a file or to preserve it in the console?

Edit: I know I can still read the info when building normally, this question is specifically for building with the debugger.

View 1 Replies

Flex :: Build Several Files In Maven Flex?

Jan 31, 2012

I can use Maven with FlexMojos to generate swf file, but because I have several mxml files need to build, could I build them in 1 Maven pom file?I know if I separate them into several projects, Maven can build them. But because these mxml files have some shared functions, it's not easy to manage if I separate them.Another question is the size of swf file. The original file size build by Flex builder is about 80KB, but the file size by Maven is about 800KB. Is it normal?

View 2 Replies

ActionScript 2.0 :: Math.min And Math.max?

Jan 16, 2004

So here is a piece of code that I have seen used a lot but don't really quite understand:

myVar = Math.min(Math.max(myVar, this.min), this.max);

or some variation thereof. I understand that the function first finds the maximum value of two values then turns around and uses that to find the minimum between two values.why this is done? And how do you know when to use it?

View 3 Replies

ActionScript 2.0 :: Math.min And Math.max

Jan 16, 2004

So here is a piece of code that I have seen used a lot but don't really quite understand:[code]or some variation thereof. I understand that the function first finds the maximum value of two values then turns around and uses that to find the minimum between two values.And how do you know when to use it?

View 3 Replies

Flex :: Use Air To Build A Chromeless CD Auto-run App?

Oct 15, 2009

We'd like to have an app autorun when our clients put in our info CD. Is it possible to do this using Adobe AIR... We were thinking of using the Flash Projector cause it compiles to an .exe which is easily launched, but there's no way to get rid of the ugly window chrome is there?

View 3 Replies

Flex :: Air - Build A Desktop Apps?

Jul 10, 2010

building a desktop app that can compile java, c, c++ files and display the results using the flex app

View 3 Replies

Flex :: Build Tooltip For Fxg Button

Feb 10, 2011

I have a nice looking fxg button, to which I want to attach a tooltip- how do I achieve that without much hassle? (the spark button does this out-of-box, but is not very visually pleasing)The examples I have seen on search is reverse- using fxg effects in the tooltip.

View 1 Replies

Flash :: Build External SWF In Flex?

Feb 24, 2011

I have a a module that I want to include in the swf build but I want the swf to be able to use the module (separate swf) externally. How can I build both the application and the module in different swf files? (I know it's something with the compiler, but not quite sure)

View 1 Replies

Flex :: Build A Template Like JSF Include Tag Or What Else?

Mar 7, 2011

I wanna creating a flex application. In that application left, down and right side will be same all pages but on center screen will be changed in order to click event. Is that possible? When i click button on the center screen, center screen will show another MXML (call another MXML but left, right and down side will be same). How can i do that?

View 1 Replies

Build A Flex Project On Ant Or Maven?

Jan 5, 2012

I am going to write a build commands for flex 4.5 project, which is only based on actionscript not with java. I am very new to both maven and ant.So can you people suggest which is more compatible and robust with Flex 4.5

View 1 Replies

Actionscript 3 :: Flex - Run Scripts Before/after Build?

Jun 11, 2009

Currently I'm building my Flex projects using Flex Builder's "built in" build system (ie, "clicking the run button"), but I'd like to start running scripts before/after the build.What's the easiest way to do that? Or, even, where should I start looking?

View 2 Replies

ActionScript 2.0 :: How To Build In Flex Or Flash

Jun 17, 2008

Anybody knows about family tree concept?How to build in flex or flash?

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved