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
Similar Posts:
Mar 16, 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.
[Code]...
View 22 Replies
Jan 24, 2012
I had an onEnterFrame script that would make a cypher of some letters for you. I thought it would be great if I could wrap the code in a function so I could apply it to multiple textboxes at once. Since doing it (wrong!) it only actually does what its supposed to on one of the textboxes. What am I doing wrong?
To make this work you'll need a two textboxes, one with an instance name of text_one and one called text_two
Actionscript Code:
// The String that will reveal itselfcypher_characters("text_one", 10, 5, 2, text_one);cypher_characters("text_two", 10, 5, 2, text_two);function cypher_characters(characters, time_until_start, time_between, frequency,
[Code].....
View 2 Replies
May 11, 2010
This is the source of my woes:[code]With just this code active (I've set up a test file), the movie clip "images" gets repositioned to x=630 at runtime. Why is it doing that? I wanted this function only to change the value of the "check1" variable, not to actually perform any translation on "images".
View 3 Replies
Jan 12, 2010
i've just written the function below and I want to perform it multiple times but with different urls,
[Code]...
View 7 Replies
Dec 13, 2010
I have some code that I want to wait until the first step of the process is done and then do the next task. But I can't seem to think of a way to do it??The full code for the entire process is this:[code]How would I tell it to wait until the first part is done to perform the second part?
View 3 Replies
Mar 26, 2012
I had a simple swf with enter frame event that would move an object. everything worked ok , then I changed the framerate from 12 to 24fps. No everything is still working ok, execpt the movement in the enterframe event seems to be working at 12fps still...
ActionScript Code:
function performonenterframe(evt:Event):void{
character.x += 5;
trace (character.x);
}
the trace now would give me 5,5,5,10,10,10,15,15,15 etc...so the event is kicking in every frame but it is moving the character every third frame only...
View 2 Replies
Jan 18, 2004
Sorry if the subject doesn't make much sense but I basically want to perform several if the statement when on movie clip is clicked. an example of an onRelease trigger that activates two if then statement that change the frames of 2 movie clips.
View 11 Replies
Jun 2, 2009
I don't know how to phrase this, but as you can see my code below I have 2 classes.
1. wp_title
2. wp_date
How can I let wp_date to get the height of wp_title's contentText? Currently I tried tracing wp_title.height from wp_date but all I get was 0, I guess it doesn't get the height after wp_title finish loaded. Currently the classes will perform an action after I resize the stage. I assume if I'm able to get the classes to communicate with each other than I could have 1 main classes to control the actions perform in other class?
Code:
package {
import flash.display.Sprite;
import flash.display.Stage;
import flash.display.StageScaleMode;
import flash.events.Event;
[Code] .....
View 5 Replies
Jan 18, 2004
I basically want to perform several if the statement when on movie clip is clicked.
an onRelease trigger that activates two if then statement that change the frames of 2 movie clips.
View 11 Replies
Feb 6, 2011
I have two InputText boxes (Flash CS5 AS3). I will perform calculations with the values that are placed inside the boxes. How can I turn their values into numbers? I will eventually restrict the boxes to numeric values only.
View 3 Replies
Feb 8, 2010
Is there a way to detect if my Vector is out-of-range before performing an action? I tried
if (myVector[i] != null || myVector != undefined) {
// do stuff here
}
But I am getting an out-of-range error.
View 1 Replies
May 6, 2010
I want to build an application using air. The application should load the flashlog file and display the contents after performing some text filtering.But when i load the application this clears my flashlog.txt though my file mode is READ.I can understand that running my air application clears the flashlog and prepares it for new logging. Is there a workaround for this.I dont want to open the flashlog file everytime and check for traces from my web application
View 1 Replies
Jan 6, 2011
could you please point me out good Flash and ASP.NET integration tutorials out there? For example reading values from FLASH text-boxes for performing queries to MSSQL databases, and writing back values to flash.
View 1 Replies
Aug 19, 2009
I have a Custom Event that takes the name of a file uploaded through FileReference and bubbles the variable back up to the parent class. The Custom Event works and when traced in the parent class, it appears the variable came through as well and traces out in the output. However when trying to use this variable in the text field and assigning it anywhere in the parent class, nothing happens, not even an error.[code]
View 3 Replies
Aug 20, 2009
I have a Custom Event that takes the name of a file uploaded through FileReference and bubbles the variable back up to the parent class. The Custom Event works and when traced in the parent class, it appears the variable came through as well and traces out in the output. However when trying to use this variable in the text field and assigning it anywhere in the parent class, nothing happens, not even an error.
parent class
____________
package classes {
import classes.gs.*;[code]..........
View 0 Replies
Dec 11, 2011
So if you press and hold a button, it does the function once, then waits 0.5 of a second or so then repeats the action quickly. How do I remove the 0.5 of a second wait?
View 3 Replies
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
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
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
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
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
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
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
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
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
Jul 19, 2005
[Code]...
How can we split this kind of calculations
View 1 Replies
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
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
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