ActionScript 3.0 :: Flash Simple Arithmetic Calculation - No 0 In Output

Feb 23, 2011

I'm making a simple calculator, where user can enter values into textboxes and then hit the calc button. E.g.
this.sales_txt.text = "8.50"
this.buying_txt.text = "3"
var marginPerLitre:Number = parseFloat(this.sales_txt.text) - parseFloat(this.buying_txt.text)
trace(marginPerLitre) // = 5.5 <--
I need the output to equal 5.50

View 1 Replies


Similar Posts:


Flash :: Math - Fast Arithmetic Using The 3d Api?

Jun 3, 2011

Some computationally intensive software are now using the GPU to solve mathematical problems. Now that flash has GPU support, is it possible to use flash to crunch math problems? How would it be done. In other words, does flash expose sufficient low level API to control the behavior of the GPU sufficiently to perform such a task? Example of problems; Find a message with the following hash: 2987432847298374298374982374

View 2 Replies

ActionScript 2.0 :: Simple Logarithmic - Get The Output Of LogB?

Oct 13, 2010

I am using Actionscript 2.0.

O_o My question is...

What script must I use?

Example.
B=20;

Then I need to get the output of logB.In other words log20 = 1.301029996.How can I get that? O_o

View 2 Replies

ActionScript 2.0 :: Flash Calculation Bug?

Feb 16, 2011

59.99 + 10 = 69.99 is true.but if we trace it with flash as bellow trace(59.99 + 10 == 69.99)it says false.is the above condition is an exception?

View 7 Replies

ActionScript 2.0 :: Arithmetic With Array Values?

Mar 1, 2007

var oth:Number = uup[0]+dup[0]I'm trying to find the sum of two array values and I'm just getting a concatenated string of the two numbers. What am I doing wrong?

View 3 Replies

ActionScript 3.0 :: Use Arithmetic Operators On Objects?

Jun 19, 2009

Does anyone know if it's possible to add objects as a whole together using operators rather than breaking them apart or using object.method() format? Below is a simple example of what I would like.

Want to do:

Code:
var obj1 = new MyClass(1,2);
var obj2 = new MyClass(3,4);
obj1 += obj2;

[Code]....

View 2 Replies

ActionScript 2.0 :: Arithmetic With Arrays And Text Fields?

Aug 6, 2010

I have been placing 'numbers' into an array via an input text field. Then on completion, I want them to be added up and the results displayed. However, what seems to be happening, is that the numbers going into the array are being read as Strings .. no good.

Code:
var num_ary:Array = new Array(5,9);
num_ary.push(input_txt.text);

[code]......

View 7 Replies

ActionScript 2.0 :: Arithmetic Addition; Joining, Not Adding?

Oct 20, 2004

I am trying to add two variables, but my AS is joining them

volume1=function(answer1){
aa=wtft*12;
aaa=wtin;[code]....

There is more to this script, but I cut it down to this in order to focus on the error, which results in a joining aa and aaa. i.e. aa=36 aaa=4 results in a=364, where what I want would be a=40

View 5 Replies

Flash :: EnterFrame Tween Calculation Returning Unexpected Result?

Mar 2, 2010

I have the following bit of code:

protected function onEnterFrame(e:Event):void
{
var diff:Number;

[code].....

View 1 Replies

Data Integration :: Php Data Correct On HTML Output But Output To Flash Is Incorrect?

Jun 22, 2006

var nextY = 0;
var nextY2 = 18;
for (var count = 0; count < result_lv.typeCount; count++)
{

[code]....

The type count is correct but the information for the project is wrong.

View 1 Replies

ActionScript 3.0 :: Trace Doesn't Output Anything In The Output Window Anymore?

Nov 20, 2009

I'm quite new to AS3 (coming from php/c#) and like it very much. My problem: trace doesn't output anything in the Output window anymore?!

View 2 Replies

ActionScript 3.0 :: Trace Doesn't Output Anything In Output Window Anymore

Nov 20, 2009

I'm quite new to AS3 (coming from php/c#) and like it very much.My problem: trace doesn't output anything in the Output window anymore?!

View 3 Replies

Actionscript 3.0 :: Math.cos - Change Arithmetic Positive Progression To Negative Progression

Jul 20, 2009

Code: Select allimport caurina.transitions.*;
addEventListener(Event.ENTER_FRAME , kop)
function kop(e:Event):void {
dot.x = mouseX ;
dot.y = mouseY ;
[Code]... 

What i done there i draw a box and made it to movieclip and instance named it hook and created a invisible dot and called it dot. Then I calculated distance from box to the mouse then i took that number and put it in Math.cos command. And finally i made tweener to change box scale depending what my mouse distance from it.So if my mouse is close the box is big , if far - box is small. Ok, I want to know is there another way to do this ? Cuz , i cant think of other way to change arithmetic positive progression(like 3,6,9,12) to negative progression(like 12,9,6,3) than Math.cos command.

View 5 Replies

ActionScript 3.0 :: Not Performing Calculation?

Mar 17, 2012

So i think i have fully coded my calculator but it still doesn't seem to be performing the calculations correctly. I can't see where i am going wrong. If i perform a calculation let's say 6*2 it outputs NaN then i straight away + by let's say 5 it outputs NaN again. And it doesn't make the operators display only once, so if i click on '+' twice it will display twice in the display when it is meant to only display once and in one of my functions i cleared the display field so that it would replace the number's when the next operation is performed but it doesn't seem to be doing that. I have been going over the code several times but i can't seem to identify where the problem is coming from.

Actionscript Code:[code].....

I have not added the full code as it is too long, i have just added the parts which relate to each other. I am just doing everything entirely through actionscript, nothing is on stage apart from the display and answer text fields.

View 6 Replies

Actionscript 3 :: Age Calculation In Flex

Mar 3, 2010

I'm trying to calculate age in flex. I've found this previous question url...[code]but I don't understand 100% whats going on.How do I go Implementing this into my code say if the date was 12/23/1990?Also How would I go about modifying this code to calculate the age if two dates are provided instead of using the current date? eg. 12/23/1990 - 10/15/1999

View 2 Replies

ActionScript 2.0 :: Calculation Of Infinity?

Dec 28, 2002

I have a actionscript calculation that initially calculates a value of infinity. Is there a "if" statement you can perform until the calculation actually calculates a real number (0-100)?

View 14 Replies

IDE :: Dynamic 3D Distance Calculation?

Jan 14, 2009

Is there a way to calculate the distance between the origin of a movieClip at, say, (x:500, y:0, z:0) and one at, (x:500, y:0, z:50)?? And lets say the vanishing point is (0,0) and the perspective angle is 50.

I know that the eq for finding the distance between two points in 3D space is:
d = ((x1-x2)^2 +(y1-y2)^2+(z1-z2)^2)^(1/2)

the problem is I dont know x2 (the x value of MC2 (the one set at z = 50)).

[URL]

View 2 Replies

ActionScript 3.0 :: Odd Calculation Error?

Feb 9, 2011

So got a very odd result from a maths operation:

Code:
var myNumber = 6.3 + 9.1;
trace(myNumber);

[code]....

View 11 Replies

ActionScript 2.0 :: Link Input Text To A Variable And Output That Text To The Output Window Using Trace

Jul 22, 2005

I'm teaching myself ActionScript and the book I'm reading just got into input text capabilities. The book shows me how to link input text to a variable and output that text to the output window using trace. My question is: how can I display the text that the user input onto the actual movie. For example... if I wanted the visitor to type their name into the input text box and click Submit and then a phrase shows up with their name such as "Hold on Name, my site will be done soon." How do I reference that variable and have it actually display in my movie?

View 5 Replies

ActionScript 2.0 :: Can't Seem To Grasp The Concept Of Arithmetic In Actionscript

Feb 5, 2009

I can't seem to grasp the concept of arithmetic in actionscript.

View 8 Replies

Flash8 :: Vector Calculation Formulas?

Apr 8, 2009

I'm making a game based on pong. At the start of a round, the ball will go in a random direction and when the ball hits a paddle the ball will move in a certain direction depending where it hit the paddle. The more centralized the hit is, the more straight the bounce is. Here's the tricky bit: the ball may hit either a vertical or horizontal paddle and I want the xspeed(horizontal movement) or yspeed(vertical movement) of the ball to increase/decrease in proportion to the opposite speed while keeping the same general speed of the ball(it can decrease and increase). Here's an example(you might want to get a pen/pencil and a piece of paper):

Let's say the ball is moving at 45 degrees(so it's going downward right) and hits a horizontal paddle smack dab in the middle, thus it goes at 270 degrees(straight up). So, at first the xspeed and yspeed are both the same, then the xspeed is zero and the yspeed is at the max(to the general speed).However, let's say that the ball hits the same paddle but at the edge(either edge will do the same) thus making the ball go at a near 360 degree angle, making the xspeed near max and yspeed almost zero. Like I said, I want the two speeds to increase/decrease in proportion to the general speed, this is so that xspeed or the yspeed don't exceed the general speed.

View 3 Replies

ActionScript 3.0 :: Auto Calculation With No Buttons?

Sep 21, 2010

I need to do a simple calculation and have it update and display the result without me having to click a button.On the stage I have two text fields.The one on the left is a input text field with the instance name of "input" (without the quotes)To the right is the other text field. It is a dynamic field with the instance name of "output" (again, without the quotes)When typing into the input field I want it to multiple the value by 10 and display the result in the output field.If I then change the input value it needs to automatically update the output field.

View 4 Replies

Actionscript 3.0 :: Dynamic 3D Distance Calculation?

Jan 14, 2009

Is there a way to calculate the distance between the origin of a movieClip at, say, (x:500, y:0, z:0) and one at, (x:500, y:0, z:50)?? And lets say the vanishing point is (0,0) and the perspective angle is 50.

And its not just straight geom because we dont know the ACTUAL x value of the second MC. It thinks its at x:500 but when you look it will look farther to the right than 500

see: [URL]

View 4 Replies

ActionScript 2.0 :: Basic Calculation Not Working?

Dec 14, 2002

EXAMPLE 1

Code:
a = 98587
b = 0711
c = a - b

This results with c = 98130 which is wrong it should be 97876.

[Code]...

View 12 Replies

ActionScript 2.0 :: Timer - How To Split Calculation

Jul 19, 2005

[Code]...

How can we split this kind of calculations

View 1 Replies

ActionScript 2.0 :: Run A Mathematical Calculation On The Data?

Apr 30, 2004

I have XML data that looks like this: 197,168,198,168,204,168,206,168,207,169,208,etc This stuff is XY coordinate pairs, X1, Y1, X2, Y2, X3, Y3, etc. and are used by a drawing function to trace out a particular freeform shape. This array of data is usually 200-400 items long.Here is the AS code that is handling the reading of the XML and the drawing of the shape. This all works wonderfully:

[code]...

I am looking at the array and grabbing some points out, namely the first and last XY pairs, which I need for something else. That's the origXexp, origYexp stuff.The real problem is that I need to run a mathematical calculation on the data in this array. While this is a little hard to explain, I need to create a variable, let's call it expert_area, and then sequentially rip through that long string of numbers and do the following math (I'll use the simple X1 Y1 example): expert_area=0 expert_area = expert_area+((X1*Y2 - X2*Y1)/2)

where we move through the long string a pair at a time. So the first calculation would be (X1*Y2 - X2*Y1), the next would be (X2*Y3 - X3*Y2), (X3*Y4 - X4*Y3), etc. I've tried building loops to get the length of the expertArray[i] and then using that as the basis to proceed through the data. But everything I try either produces no results, or gets Flash stuck in an infinite loop. I'm unsure of where to put this, and how to construct it.

View 3 Replies

IDE :: Round Off A Calculation To 2 Decimal Points?

Feb 15, 2005

The following is the code for the press button:

Code:
on (press) {
var charges:Number = Number(charges_txt.text);
var payments:Number = Number(payments_txt.text);

[Code]...

on the dynamic text labeled PERCENTAGE I cant get it to give me just 2 decimals.

View 2 Replies

ActionScript 1/2 :: Make Formula For Calculation Of Speed

Jan 3, 2011

I´d like to know how would I make a formula for the calculation of speed.It´s not as simple as distance divided by time.I want something different.I have an helicopter.This helicopter is landed.He will take off with a small speed, but increasing speed.What I want is.This helicopter movement. In other words, increasing vertical speed, in a given time, say, 2.4 seconds, in a give distance, say, 100 pixels.After that he keeps vertical speed constantly. So I think the helicopter will start with its vertical speed slow, increasing, then, decreasing untill it reachs its constant vertical speed.

View 1 Replies

Flex :: Get A Stage Calculation To Resize An Image?

Jan 4, 2010

I am trying to center an image in the middle of the stage and scale it proportionally to the correct aspect ratio based on its loader's size when the image is loading.

In my main app runner I do:

private var rec:Rectangle = new Rectangle();
private var img:BitmapDisplay = new BitmapDisplay();
stage.addEventListener(Event.RESIZE, setRect);
img.imageURL = "some/path/to/image.jpg";
addChild(img);

[Code]...

View 1 Replies

ActionScript 2.0 :: Calculation Of Frames In OnEnterFrame Loop?

Jul 9, 2010

I'm trying to work this out if anyone can help. I have a function:[code]....when I pause the movieclip set at 30fps the sec,min stop but the frame var keeps running in the onEnterFrame loop. Basically I am trying to count frame by frame in a movieclip, and every 30 frames the frame var will reset to zero.

View 9 Replies







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