Flash :: Calculating Distance Just From Speed?

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


Similar Posts:


ActionScript 3.0 :: Calculating The Distance Between Two Images?

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

ActionScript 1/2 :: Calculating A Distance Between 2 Movie Clips?

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

ActionScript 2.0 :: Calculating The Distance Between Array Indexes?

Nov 4, 2007

im having difficulties calculating the distance between array indexes. for example:

Code:
chararray = new Array(" ", "_", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");

this is my array... and now i want to calculate the distance between 'X' and ' @'. This should be 6. How should this be calculated?

View 5 Replies

ActionScript 2.0 :: Calculating Distance Witin A Movieclip That Moves?

Dec 8, 2006

I am trying to modify this code that is attached to and alpha engine. It is the same code from the tutorial: Calculating Distance

onClipEvent (enterFrame) {
xdist = Math.round(_root._xmouse - _parent._x);
ydist = Math.round(_root._ymouse - _parent._y);[code]....

What i need to know is whether or not i can modify this to calculate the distance of the mouse from the clip, even if it is contained in another clip that moves around the stage.

View 1 Replies

ActionScript 3.0 :: Racing Game - Calculating X And Y Speed

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

Actionscript 3 :: Calculating The Current Upload Speed (or Throughput)?

Jun 28, 2010

I am uploading files using the upload() method of the FileReference class. I want to display the current connection speed and I was wondering what was a good way to do that.

My current technique is to use a Timer every 1 mili second such as follows:

var speed:Function = function(event:TimerEvent):void {
speed = Math.round((currentBytes - lastBytes) / 1024);
lastBytes = currentBytes;
}
var speedTimer:Timer = new Timer(1000);
speedTimer.addEventListener(TimerEvent.TIMER, uploadSpeed);

and currentBytes gets set into the ProgressEvent.PROGRESS. This technique seems imprecise. I was wondering what other ways I could use to calculate the upload speed while uploading and display it in real time.

View 2 Replies

Android :: Calculating An Angle Using The Law Of Cosines, Given 2 Points And Calculating 1 Point?

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

ActionScript 2.0 :: Distance From Center - Output Distance Only In Positive Numbers

Jun 17, 2005

I am working on the project where everything is based on the distance from the center of the stage. First I made this fla where flash outputs the x and y distance from the center. First problem is that I want to output distance only in positive numbers.

View 1 Replies

ActionScript 3.0 :: Making Distance Between All Mcs At Equal Distance From Each Other On Mouseover

Oct 16, 2010

I am posting my code that attaches the movieclips on stage

[Code]...

i was hoping that when the newMc expands, all other mc would keep the same distance between each other as at initialisation. I not able to figure how to do it. maybe even an earlier post or llink where similar query was explained.

View 1 Replies

ActionScript 3.0 :: Get The Distance Between 2 3D Objects By Using Distance Method

Apr 28, 2011

In AS3 I am trying to get the distance between 2 3D objects by using distance method.
  
if(Vector3D.distance(model.position,model2.position) < 100)
{
// do something

[Code]....
 
>>You can use it directly as a method of the Vector3D class to get the Euclidean distance between two three-dimensional points.
 
Which point does this method pick? Is it the closest point to the other object ?
 
I am just thinking of how much time this would take in testing objects with large poly count.

View 1 Replies

Flash :: Adjust The Speed Of The Tween To Ensure A Consistant Speed Regardless Of The Value Of StartX?

Dec 13, 2009

I'm tweening a movieclip from startX to finishX. The value of startX varies but finishX is a constant. But as the startX increases in value the animation appears to be quicker. How do I adjust the speed of the tween to ensure a consistant speed regardless of the value of startX?

View 1 Replies

ActionScript 3.0 :: Flash - Calculating Progress Bar Size?

Jan 12, 2011

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

Code:
var parcialSeek
var completeSeek

[code].....

View 4 Replies

Professional :: Change Speed Of Symbol Without Changing Speed Of Entire Movie?

Aug 7, 2010

I want to add an animated .gif file to my movie.  So I created a new symbol and then imported the .gif file to the stage.  This created the symbol containing the animated .gif.I dragged the symbol onto the scene where I want it.  However, the animation seems to play at a different speed (fps) than normal.  So I changed the fps of the symbol (at bottom of Timeline where it says "fps").  But for some reason this changes the fps of the rest of the entire movie.

View 3 Replies

ActionScript 2.0 :: Change A Songs Playback Speed Depending On A Speed Variable?

Jul 24, 2009

is there anyway to change a songs playback speed depending on a speed variable. heres the kicker tho im limited to using only as2.

View 2 Replies

Flash :: Calculating Text Width In ActionScript And Flex?

May 26, 2010

I'm trying to calculate how WIDE to make my button, based on the text that it will contain, and when I try to google for how to calcuate something as simplistic as the WIDTH OF SOME TEXT, I go cross-eyed just trying to wade through apparently nonsensical esoteric counter-intuitive voodoo. how I would write a function like this:

public function HowWideWouldThisTextBeIfItWereInThisButton(Text:String,Container:Button):int {
...
}

View 6 Replies

ActionScript 3 :: Flash - Calculating Frame Independent Acceleration?

Jan 17, 2012

I have a 2D side scrolling game (made with ActionScript 3) that runs at 60 frames per second. I'm trying to make it frame rate independent so it will run on slower devices.

To do this I create a var called timeElapsed by calculating how many milliseconds have passed between each frame and dividing that by 16 (60 fps is about 16ms, I think.) So that at 60 fps the result would be about 1. Then I times any time related vars by this number (e.g player.x = speed * timeElapsed;) This is the code:

private var oldTime :Number;
private var defaultFrameRate :uint = 16; // the default frame rate in milliseconds
private var timeElapsed :Number;

[Code]....

As you can see, at 30 frames per second the player is moved further in the same amount of real time. What seems to be the issue is that, at 30fps in frame one, my current code doesn't account for the slight difference in speed between frame one and two at 60fps. I thought of getting the average value of speed between any two frames at 60fps and using that to calculate a more accurate value when the frame rate changes but I got the feeling wouldn't work correctly in some other situations since at 60fps for example, it would move the player by 115 and not 110 pixels.

Is their any way to accurately simulate an object accelerating in a way that is frame rate independent?

View 1 Replies

ActionScript 3.0 :: Flash - Calculating Order Of Boxes As Per There Position

May 28, 2010

I am working on sequence quiz engine. I have a function to sort boxes (dynamically generated Movieclips) which calls on every release of boxes.

[Code]...

View 1 Replies

ActionScript 2.0 :: Increasing Enemy Speed /cannot Seem To Change Speed

Mar 23, 2010

I have a movie clip on my scene which has a speed applied to it making it move across the screen. This is duplicated when it reaches the other end of the screen.On my scene I have some action script which is acting as a timer. After a set time I want it to increase the speed of the movie clips, making the game become "harder". I seem to be able to manipulate the alpha of my movie clips but can't seem to trigger the speed increase.If i use a setInterval it seems to trigger the speed increase but it does it each time the movie clip is duplicated (so the delay resets, it does not change once and apply throughout)However, where I am changing the alpha I cannot seem to change the speed.

View 2 Replies

ActionScript 3.0 :: Detecting Mouse Speed And Put Speed Limit?

Sep 20, 2009

How can i detect mouse speed with AS 3.0, and then put speed limit? Also can i use speed var for anything else? *sorry for my bad English, i live in non-english-speaking country*

View 9 Replies

Flash :: AS3: Find Distance Of Rotation

Sep 20, 2011

I am rotating an object with TweenLite, however instead of a set duration I want the duration to be based upon the distance of rotation where 180 degrees = 3 seconds 90 = 1.5 and so on. Here is my attempt to find the distance of rotation:

var time:Number = Math.abs(Math.atan2(Math.sin(angle-wheelObj.rotation),Math.cos(angle-wheelObj.rotation));
TweenLite.to(wheelObj, time, {shortRotation:{rotation:angle}, ease:Expo.easeOut, onComplete:rotateWheel, onCompleteParams:[target]});
TweenLite.to(carObj, time, {shortRotation:{rotation:angle}, ease:Expo.easeOut});

This just isn't working, time is sometimes huge when the rotation is small and sometimes tiny when it is big, so does anyone know a better way to do this?

View 3 Replies

Flash :: Finding Shortest Distance / Route On Map?

Aug 9, 2011

In Actionscript, I'm trying to work out the best way to create the shortest route between two point on the map above. I have all the distances.

Algorithms like A* I dont think are relevant as it is near impossible to work out the heuristic distance.

I thought I could create a big array of all the nodes with the distances to any connected nodes and just iterate through until Ive found the the shortest distance, but this I know is very inefficient.

View 2 Replies

ActionScript 3.0 :: Flash - Limit The Distance On X Axis?

Jan 4, 2011

example im dragin one mc object. with as3 code, and when im draging i want to do next:now if(400<mc.x<450) {trace("WIN DUDE XD")}[how to make that interval ?!(how to set that condition in "if" statement)every time when i drag my mc is between 400 and 450 on x axis, to trace Win

View 2 Replies

ActionScript 3.0 :: Flash Travel Distance Calculator

Jan 18, 2011

I am given a task by my client to develop a calculator which will calculate the Cab fair from one location to another. There is a list of Cab fairs as well as their corresponding Location Name. It would be displaying the results on the screen.

[Code]...

View 1 Replies

Actionscript 3 :: Flash - Space Characters At A Defined Distance From Each Other?

Nov 10, 2011

I need to create a 'rolling' percentage text field, the only problem is as the size of the characters changes, the text jolts a little from right to left and back.How can this be overcome for a smoother effect?

private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);

[code]......

View 2 Replies

ActionScript 3.0 :: Flash - Keep A MC A Certain Distance From The Mouse Cursor Regardless Of Angle?

Jun 9, 2011

How to keep a MC a certain distance from the mouse cursor regardless of angle?

View 10 Replies

ActionScript 2.0 :: Detect A PC Speed Our Cpu Speed?

Jul 16, 2005

How can I detect a PC speed our cpu speed with actionscript?

View 1 Replies

ActionScript 2.0 :: Textfield Width Based Upon Distance To Edge Of Flash Movie

Mar 22, 2010

I've got a textfield creater that creates a nice textfield when I hover over a moveable button. However, when I click and drag that button around the flash movie, the text field disapears off the edge of the screen if I get to close to the right side. Can I adjust the width of the textfield as the mouse is moving closer to the edge?

View 0 Replies

ActionScript 2.0 :: Calculating A String Value

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

ActionScript 3.0 :: Calculating Pixels In Squares?

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







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