ActionScript 2.0 :: Calculating Two Positions, In The Middle?
Oct 22, 2007
I know how to calculate the distance between two movieclips, but I want to know how do you keep a movieclip centered between two movieclips? For example, three movie clips evenly spaced out in a row. I drag either movie clip on the end and the one movie clip in the center positions it self to be in the center x and y wise.
View 9 Replies
Similar Posts:
Jan 13, 2009
what I am trying to do is calculate the position of a point along a curve, what I want to do is create a function where i am able to determine where a point intersects the curve when I provide an X value.I have created a simple diagram to illustrate what I am looking for:So assuming I know the x,y of each black dot, and the x of the red dot, how do I calculate it's y value?
View 2 Replies
Dec 27, 2011
I am developing a game for mobile in AIR (as3). I have created some bots for this game that initially just wander around. But when a bonus enters the stage, they have to move to the bonus.The detection of a new bonus and moving of the bots works fine, but there is something wrong with the manipulation when a new bonus enters the stage.Basically, this is how it works (or I try to make it work):My bot moves along with his rotation as a parameter. (works fine)
private function moveToNextLocation():void
{
var angle:Number = _rotation * 0.0174532925; // 1 degree = 0.0174532925 radians
var speedX:Number = Math.sin(angle) * _speed;
[code]....
View 1 Replies
Jan 22, 2007
I have thumbs placed on the stage. I create an empty mc to load swf. But my thumbs disappear from the stage when I test the movie ( html or swf) if I settle the _ and _y position of the empty mc.why the emptymovieclip positions affect the positions of my thumbnails?
View 2 Replies
Nov 5, 2007
I've used the countdown AS from Kiruba to list a value of days left until 2008.[code]I want to calculate 1580 - (this.digit * 4) and have a new this.digit value of 1364.
View 4 Replies
Jan 27, 2009
I have a math issue that I have some problems solving.
screen1
screen2
I need to calulate the pixels inside the squares and put them inside an array:
The main square rotates(see screen2) and i have the angle.
Something like attached code.
I have the following values:
- x/y of the main square. ( reference point )
- Width/height of the main square
- Width/height of all the squares
- Angle of main square..
View 8 Replies
Jan 12, 2011
trying to calculate the size of a progress bar.Here is the thing I have a movie with X scenes and I want the progress bar to fill up according to the porcentage of my timeline that has passed.here is the code I'm using
var parcialSeek var completeSeek
this.addEventListener(Event.ENTER_FRAME, tamanhoBarra) function [code]...
with this code every new scene the bar starts again and since I don't have exacts 100 frames on my movie the bar size dosen't match?
View 3 Replies
Mar 1, 2011
As the title says I am looking for a loop sequence to search through my array and find values that are even and then calculate them with a button click. I have this code which is completely wrong:
[Code]....
View 1 Replies
Dec 9, 2011
I'm trying to calculate the distance between two images (A and F - there are other images between A and F) but I can't seem to figure out how to do it the right way. The image A.x is "(stage/2) - (A.width/2)" and image F.x is "E.x - imgSpace" which is a negative value (all the images x is of negative value to image A.x). In my oppinion the calculation is F.x - A.x and although it might be right I still ned the value to be non-negative.
View 3 Replies
Mar 26, 2011
Count = "400"/3 - 1;
How to convert the above count to int?
View 2 Replies
Jun 17, 2011
I'm creating a drag based control in Flex / Flash, similar to a film strip, where an individual can swipe horizontally to scroll through the items. To make the control feel a bit more natural I've added some inertia to slow the scrolling once a swipe has taken place. When first loaded up there will be five items in view with 'x' numbers of items to scroll through with the 3rd item centred and selected.
My problem though is that I want, when animating, a swipe gesture to determine whether an item will end up the middle (3rd position) and adjust its movement calculation accordingly so it docks with the 3rd / centre position. Imagine you perform a long swipe, it flys pasts 'x' amount of items, but as it slows to a stop it elegantly stops with an item centred / in the 3rd position. To do this I believe I need to determine the distance to travel just from the speed value (as time is irrelevent to the user experience, i.e. a longer / stronger swipe would justify a longer animation skimming through the items).
At the moment I'm invoking the animation routine (with inertia) in the ENTER_FRAME event when the user generates a MOUSE_UP event. When they do this, I obtain the speed of drag (by monitoring this beforehand) and then decrement this speed value on each call of the ENTER_FRAME event until it reaches an appropriate value to stop the animation.
Unfortunately all the speed calculations I've seen deal with Speed and Time to determine distance, I just need Speed. Admittedly, my knowledge isn't strong in this area so I might be missing the obvious.
View 2 Replies
Sep 7, 2010
I want to create one calculator which will calculate the future cost of education after certain years like 10 or 15 yr. If i take the inflation rate as 10%. How to calculate the future cost.I don't have any idea about it. I want to know the formula to get the output.
View 3 Replies
Nov 8, 2010
This is actually more a math problem, but maybe some of you are better at math and have an idea on how I should be approaching this.
I'm dynamicly creating circles in my actionscript project and what I want now is calculate their x- and y-positions. I want them to be positioned in a circle, with the condition that it shouldn't matter how much circles I dinamicly load. (I'm having a hard time translating my problem to English, so I'll add an image so you instantly see my problem.) Does anybody have an idea on how to calculate this? What kind of formula should I use?
View 5 Replies
Jul 8, 2011
I am wracking my brain over how to figure this out and it is REALLY frustrating me. If we have a cannon on a castle wall that shoots a cannonball from (0,0) toward an enemy that sits below on the ground off to the right at (50,-10) and we want the cannonball to always reach 20 units in the air, how do I make a line function where I can plug x in (which will be 0-50) to calculate y out?
y = -a(x - h)^2 + k
is the equation for this where (h,k) is the vertex. This means k will always be 20. I know to keep 'a' negative because that will give an upside down U parabola. But how do I figure out what 'h' and 'a' are? Systems of equations? How on EARTH would I write a function to do that in Actionscript?
View 0 Replies
Feb 2, 2012
Im using the as3CoreLib JPGEncoder class to save a jpg of my swf from flash.Right now I have the quality of the jpg set to 60 like this:ActionScript Code:var jpgEncoder:JPGEncoder = new JPGEncoder(60);I'm trying to set the quality number to a variable to be defined a function that will calculate the compression value needed to get the jpg to 20k.
View 2 Replies
Feb 1, 2009
i am tryIng to ceate a Scrolling message box,
i have created a dynamic text box ( instance name = scrollTextBox var = scrollText )
i use the script -
var textLength= scrollText.length;
to try and obtain the amount of characters / pixel length of the scrollText var / text file
however, regardless of whats contained within the scrollText document i keep getting the textLength return of 20 ?
my code so Far is -
Code: Select all// Load Text and adjust the DynamicText Box size to match the content
loadVariables("scrollText.txt","");
scrollTextBox.autoSize = "left";
[Code]....
View 1 Replies
Feb 5, 2012
I have some buttons that you press and it makes different types of toppings appear on a burger, but I'd like there to be a cost attributed to each topping and a running total showing the cost in the bottom right corner. The cost must be deductible if the toppings are removed.
View 4 Replies
Jul 22, 2010
I'm trying to jump to a position in the mc by clicking on a progressbar that is 388 pixels in width the total frames of the mc I am trying to jump to with the progressbar is 3348 my function is:
Actionscript Code:
progressBarMC.progressBar.onRelease = function(){ mc.gotoAndPlay(mc._totalframes / this._xmouse * 24); trace((Math.round(mc._totalframes / this._xmouse * 24)));};
View 3 Replies
Jan 14, 2010
i'm in the middle of attempting to write my own collision detection algorithm because the built in 'hitTestObject' function seems to be incredibly inaccurate (it's registering 'hits' when the objects are still a considerable distance from each other).I need to be able to calculate the position of each of the 4 corners of a rectangle, based on its rotation. Obviously one of the corners will simply be the rectangle's x and y coordinates. I have made a little test program to make sure I am calculating the positions of the corners accurately - it works when the rectangle is rotated to 0, 90, 180 and 270 degrees, but produces strange results for any other angles.[code]
View 7 Replies
Dec 15, 2010
I am creating an app that has to load a image or swf on to the stage and dynamically place and position it on either sides of the stage i.e. (top, left, bottom or right).how can I dynamically calculate the remaining bounds of the stage using the bounds of the dynamically placed loaded image/swf. ?e.g if the bounds of the loaded clip isRectangle(x=10, y=10, w=250, h=800);What is the remaining Rectangle() to use ofRectangle(0,0,1024,800); ?
e.g if the bounds of the loaded clip is
Rectangle(x=0, y=0, w=800, h=50);
What is the remaining Rectangle() to use of
[code].....
View 3 Replies
Jun 2, 2011
What is the correct syntax to calculate an XML object's loading status and relay the value to a movieclip? I'm using the following, but nothing's happening. The math is being loaded but the movieClip doesn't change size.
xmlLoader.addEventListener(ProgressEvent.PROGRESS, barProgress);
function barProgress(event:ProgressEvent):void {
var loaded:Number=event.target.bytesLoaded/event.target.bytesTotal;
barPro.scaleX=loaded;
}
My barPro movieclip remains the same size.rong?
View 15 Replies
Jul 11, 2011
I need to calculate resolution of an uploaded image in Flash/AS3.
View 1 Replies
Sep 28, 2011
I have two movie clips. One is simply on the screen, meaning it can be referred to as _root.movieclip1. The other is within another movie clip, like _root.movieclip2.movieclip3. How do I calculate the distance between the movieclips 1 and 3? The third's coordinates are shown not as they would be on stage, but from inside the second movie clip. I'm using Macromedia Flash Professional 8.
View 1 Replies
Aug 5, 2010
I have a couple of images, representing tents, that look like this: The red and blue parts on each side of the tents are doorways, and several tents can be connected together via these doorways. For example, I want to connect the two blue doorways so that they match up like in this picture: If the first tent is stationary, around which point do I rotate the second tent and how do I calculate where to place it?
Currently, I have the upper left corner of each doorway as an x and a y value, together with the width and direction (in degrees) of the door. I'm treating the doorways as one dimensional, so they don't have heights. Would another representation suit this better? Perhaps a start point and an end point plus direction?
View 1 Replies
Nov 3, 2010
I am treating a spark TextArea as text input(by setting heightInLines="1"). The TextArea is part of an mxml component and I want to resize the component when the text is changed.
I haven't been able to use textArea.measureaText(textArea.text) to get line metrics and use it. I get this error "Parameter antiAliasType must be non-null."
Is there any way to get the width of a TextArea which it is going to consume at runtime for a particular string or a particular TextFlow?
View 1 Replies
Sep 6, 2011
I've a movieclip representing an arrow (with registration point in its middle). When I click a button, the arrow must point to a certain movieclip on stage. I use this code to execute the Tween:
TweenLite.to(arrow_clip,1,{rotation:degrees});
But I can't understand how to calculate the degrees. I tried the following with no luck:
var degrees =Math.atan2((clip.y-arrow_clip.y),(clip.x-arrow_clip.x))*(180/Math.PI);
I found the following is working but I can't completely understand why:
var degrees = -(Math.atan2(arrow_clip.x-clip.x, arrow_clip.y-clip.y))*(180/Math.PI);
View 3 Replies
Feb 5, 2009
I have a text, e.g. "hello world". I want to know, what's exactly the textwidth and textheight in pixels depending on a certain font, e.g. Arial, 12, bold. Is there a possibility to calculate the exact size?
View 8 Replies
Nov 5, 2009
I have a rectangle that I can calculate the corners of and I can detect a point within that rectangle, how do I determine the 2D-coordinate of that point if I were to try and project it on a non-distorted rectangle?
Code:
|
|
|
| |
[Code]....
I've tried many a Google search dealing with 3D Projection and and matrices, but I don't even know if I'm looking for the right things.
View 8 Replies
Nov 12, 2009
I'm building a top-view racing game and I'm using the uch published code to calculate my x and y speed:
speedx = Math.sin(rotation1*(Math.PI/180))*speed*-1;
speedy = Math.cos(rotation1*(Math.PI/180))*speed;
My question is, how can I modify this code to give the car more of a rally-style movement whereas it will go sideways as I go around corners?
View 1 Replies
Nov 22, 2011
i have a small challenge calculating and evaluating a predefined path
here is my challenge in short.
- i got a path as a single color line on a white background (bitmap object but could as well be a vector shape)
- the path is a closed loop path (like a twisted and bend circle, let's call it a bean shape).
- i then need to move an object along this path in x steps but only once and stop exactly where it started
This means, i need to:
- find a start end point
- calculate the length of the path
- set keynodes along the path with X amount of spacing between (length/x)
- it got to be semi precise (within 1-2 px.)
one idea could be to loop throught the pixels till to find a color pixel and use this as the starting point, then use an vector with a predefined length (ex. 5 px) "rotate" it till it find a new color pixels and mark this as a new node, repeat the process till you get close to the starting point, and by using Trial and error you'll eventually have mapped the path, but this method is clumsy and not very accurate, if you don't hit the starting point spot on the first time, you'll recalculate everything over again.
View 4 Replies