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?
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?
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?
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?
I have created a flash 3d racing game which relies heavily on AS3's Math functions (sin, cos, tan, asin, acos, atan). It also makes heavy use of Matrix3D and Vector3D functions. The game works great on a PC, but the cars flip around and display innacurate positions on Mac computers. I know this is an issue due to the note on the Math docs page: [URL]
which states: "Note: The Math functions acos, asin, atan, atan2, cos, exp, log, pow, sin, and sqrt may result in slightly different values depending on the algorithms used by the CPU or operating system. Flash runtimes call on the CPU (or operating system if the CPU doesn't support floating point calculations) when performing the calculations for the listed functions, and results have shown slight variations depending upon the CPU or operating system in use."
how do I get this game to work on a Mac? I've tried using lookup tables and inline FastMath style approximations. But lookup tables still create the same problem, and the inline approximations I have found are not accurate enough for my game. I've also tried rounding values with floating point errors, but that has not seemed to help (in my implementation) either. I think the specific problem is with the use of Math.atan. I have not found an accurate approximation for this.. but I maybe that is not even necessary.
What is math.round() do? In kirupa's Random numbers tutorial, he explained the use of math.floor(), but said round() was for another time. Yet I see that, and not .floor() in use in the random movement tutorial.
here's where all you math genius' get to help me out. I know that this principal is not difficult and was taught sometime during my highschool years.I need a math formula which reduces the ratio of any x:y to the smallest quanity possible. Basicaly so that the smaller of the two numbers is 1 and the other number is whatever it would be, compared to 1... but, I need it to work for both posative and negative numbers.(I'm the ultimate Math newb.. bear with me)
so. I have x=20, y=20 is 1:1 -20, y=-10 is -2:-1 x=10, y=-5 is 2:-1 ect.
Envrironment: Flash CS3, AS3 I have a horizontal image scrolling project that I am working on, and it works but is not super smooth, I would like it to be smoother when it scrolls, and realize that this is a function of pixels scrolled over time and the FPS of the document.
Right now I am moving the items 1 pixel at a time on a timer with delay of 8 to get it to scroll at the speed I want. I am moving it at 1 pixel in order to catch exactly when an object should wraparound to the beginning of the scroller to show up again. So I don't know that I can really change the number of pixels moved to more than 1 and still have the images spaced perfectly, which makes me think I need to increase or decrease the FPS and or the timer delay to make it scroll smoother. Right now it is at 30FPS and as mentioned the timer delay is 8. Small changes to the delay is not a problem.
This is one aspect of flash i don't fully understand. I would really like to know how to figure this out so I can apply it to future projects as well without doing trial and error to make it smooth. Can it be function, like a way to figure out I need to move a 120pixel picture 60 pixels in 2 seconds, what should my FPS be and the picture size and movement size and number of seconds can be variables?
this math isn't working well. I'm using it for a rotated drag and drop (of a tone arm on a vinyl, a kind of abstract turntable simulation). Right now it just moves a bit in the middle of the vinyl (values between 21 and 36, is this degree or what unit is this?), but it should move between the two edges. The problem is that I don't know enough about trigonometry functions. Therefore I can't optimize the math for envisaged behaviour. Does anybody have an idea/tip how I can get a bit more control on the math and its effect? (maybe with more trace functions)
Set variable as numbers var monthly_num:Number = 0; var ttl_num:Number = 0; var ttl_rev_num:Number = 0; // user-entered numbers from an Input textfields monthly_num = monthly_txt.text; ttl_num = ttl_txt.text; // Multiply two user-entered number together to get new result ttl_rev_num = ttl_num*monthly_num;
Attempts to assign numbers typed into textfields to numeric variables causes errors. 1067: Implicit coercion of a value of type String to an unrelated type Number.
I'm not that good with Math and i have a formula for a that it's universal from what i understood but i dont know how to transform it to work with Flash's Math API.
I'm generating a random number between min and max with this code:return min + (max - min) * Math.random();And it works. However, the random numbers are very little usually between "1 or 3" even if the max is 80.
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
I think I broke my Flash. I'm using Flash CS5.5, and when I use AS3, any references to the Math class give me errors like this:1061: Call to a possibly undefined method sqrt through a reference with static type Class.1061: Call to a possibly undefined method pow through a reference with static type Class.1061: Call to a possibly undefined method pow through a reference with static type Class.The code in error is this:var dist:Number = Math.sqrt(Math.pow(initPos.x - pos.x, 2) + Math.pow(initPos.y - pos.y, 2));What the heck is going on here? Math is a top-level class, so I don't think I should be getting an error like this. Is it possible to somehow "break" the Math class? If so, how do I fix it?
I have an app (historical timeline) in which I am using one object (driver) to scroll another (driven) - like a scrollbox.There are limits on the movement of the driver, so I am using the % of the driver's movement to drive the % of the driven object's movement. It works fine on the ends of the driven, but I need to distribute the movement so that the driven object moves more at the end than at the beginning.Basically I need to multiply the % so that it moves from 0 - 1 non linearly.
I'm used to applying basic friction like this:[code]The problem is I don't know how to convert this to be described over time, so that can reduce the value based on the amount of time that has passed.Say I want to reduce the value to compensate for 1 second passing, or 500ms? How does that work in to the equation?
Strangely, the object flies up after a short while, meaning it floats up and down, but more up than down, even if the script itself is pretty straightforward.
how to code where it should move towards (that's easy), and I know somewhat how to use math stuff on flash. But when I tried to implement it on this, it doesn't work. See code:
I have a function that creates a Movieclip every two seconds. I want each Movieclip to go to a random frame. But if there is already a Movieclip on the stage that is currently on frame 4 (for example), then no other Movieclips can be on frame 4 until the other Movieclip on frame 4 is removed.
Ok this is more of a math issue than an AS issue, but in flash player 10 you can have an area of less than 16777215 pixels in order to make a BitmapData. The problem is I have an image bigger than this and for some reason I can't logically develop an equation that will take an image bigger than the resolution and scale it down so it's right under it in, and was curious if anyone has done this before.
Example: if i was trying to get something under 5,000 pixels and I had an image 300x60 that is a resolution of 18,000 what multiplier would i use on the height and width of the image so it stays the same aspect ratio and stays under 5,000 pixels.