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
Similar Posts:
Oct 24, 2010
I programming a calculator, I get data on Yahoo Finance ( URL... ), but sometimes I get this error "NaN".URL...[code]
View 1 Replies
Feb 18, 2011
I'm trying to decompile a .swf doc and extract the formulas embedded in it, in order to create a .xls document with the same formulas and creating the same charts shown in the .swf. I can't manage I will forward the .xls.
View 1 Replies
Sep 25, 2010
Does any one know of an actionscript function or class to convert strings representing math equations (like: "integral(e^(1/2), a, b)" ) into nicely formatted formulas, for display purposes (using the integral glyph, etc..) ?
Purpose: I need to display nice looking math formulas that have been entered as strings (without special characters) in an xml file.
View 6 Replies
Sep 13, 2011
I'm getting
ActionScript Code:
1067: Implicit coercion of a value of type
__AS3__.vec:Vector.ie.aro.floorplanviewer.model.buildingVOs:ConfigurationVO>[code]....
which surprises me as ConfigurationVO inherits from NodeVO.Is the compiler really not able to figure out that a Vector of a superclass should be able to hold a reference to a Vector of a subclass?
View 7 Replies
May 7, 2010
I need to import a bunch of vector work from Photoshop into Flash. Is there a trick to it. So far, on import, it's converting the layer styles into black.
View 5 Replies
Jul 23, 2011
If I want to pass in a vector to a function, a vector of any object specifed would it be someVetor:Vetor.<T>? beause FB 4.5 sais T is undefined.
View 10 Replies
Dec 24, 2010
Created Vector with the initial length of 100.
var v:Vector. = new Vector.(100);
v[90] = "Ninety"
v[190] ="oneninety" //RangeError: Error #1125: The index 110 is out of range 100.
//How to change the length from 100 to 200 to store a value at index 190
View 1 Replies
Nov 16, 2011
I am currently being confused by the Vector class.I wrote a beautiful XML to TypedClass parser. Works beautifully and without fault. UNTIL a co-worker noticed we got a Conversion Error for Vector.<Number> to Vector.<*>.
Every Vector I've ever tested all extend Vector.<*>.
Vector.<Sprite>, Vector.<String>, Vector.<Point>, Vector.<Boolean>, Vector.<TextField>, Vector.<CustomObject>, etc etc etc. ALL of them.
<type name="__AS3__.vec::Vector.<String>" base="__AS3__.vec::Vector.<*>" isDynamic="true" isFinal="false" isStatic="false">
<extendsClass type="__AS3__.vec::Vector.<*>"/>
[code]...
But then when I use describeType on Vector.<Number>, Vector.<uint> and Vector.<int>.
<type name="__AS3__.vec::Vector.<Number>" base="Object" isDynamic="true" isFinal="true" isStatic="false">
<extendsClass type="Object"/>
<constructor>
[code]....
Now I have accounted for these 3 vectors individually as even uint and int does not extend Vector.<Number> as I would have expected.
And my parsing function works for all types correctly again. But my confusion comes as to WHY this is the case, and why I couldn't find any documentation on the subject.
View 1 Replies
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
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
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
Mar 11, 2011
Class ShootGame implements IGame{
[Code]...
View 1 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
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
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
Dec 18, 2009
Basically I have used PerspectiveProjection so I may rotate multiple images about their centre so they don't appear differently rotated because of their x-position on the stage.My problem is calculating the width of the rotated images. When I rotate an image 45 degrees, my width ends up being ~146, but based on the following (my comments from my code), it should be closer to 141:
Code:
// ^C
// / |
[code]......
View 7 Replies
May 5, 2010
I'm trying to display a range of dynamic textfields, using an array.
I can place everything on the stage fine, but I just can't figure out the maths behind placing each textfield next to each other horizontally. So, despite the length of the word, the spacing between each textfield is the same, e.g. 10px.
I'm sooooo eager for this one little calculation!
Code:
var myArray:Array = new Array("little", "looooooong", "huuuuuuuuuuuuuggeeeeee", "tiny");
var container_mc:MovieClip = new MovieClip();
container_mc.x = 80;
[Code]....
View 2 Replies
Jul 27, 2010
im new to Action script 3 and im having problems i cant get a calculation to work across multiple frames and then to have the answer passed to an other frame plz help
View 1 Replies
Aug 15, 2011
I am in a requirement where I need to calculate the bandwidth usage of rtmp streaming. Is there any way I can calculate the number of total bytes I have download during the rtmp streaming?
View 2 Replies
Jan 16, 2010
I've created a series of calculations, and I've got that part down. Now, I just need it to show up in the movie.
I've created the dynamic text box in Flash (CS3), but when I hit test, it won't show up.
After all the calculations, I should have a figure that I call totalmoney. My dynamic text box is called total. The user doesn't need to hit anything for it to appear. It just appears as part of the movie.
Here's my code:
stop();
var startDate:Date = new Date(2010,0,12); // use your startyear, startmonth, startdate in the new Date() parameters.var currentDate:Date = new Date(); // assuming user's clock is correct and in your timezone. else use server
[Code]......
View 5 Replies