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


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

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

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 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 :: Using AddChild With An Array Containing Indexes?

Feb 18, 2012

so i have an array containing many instances. let's say movieclips.

and i have another array which contains numbers..in this case those numbers represent selected indices that i've somehow chosen!

var manydots:Array = new Array ();
for (var i=0; i<10; i++)
{
var newDot:dot = new dot ;
manydots.push(newDot);
}
var indices:Array = [0,1,5,8,4]

i want to use AddChild to add those movieclips into my scene, but not all of them, only selected indices contained in my 2nd array

View 2 Replies

ActionScript 3.0 :: Access Multiple Indexes In An Array?

Jun 2, 2010

I don't seem to be able to find some info regarding this problem of mine anywhere...I would like to be able to access multiple values in an array.Let say I have an array with the index values 0, 1, 2, 3, 4, 5, 6, 7.These values will in reality be posts of htmltext for a news section - contained in an external xml-file.I would like to access these "values" like so:0, 1, 2 and then if you click a forward button the next three indexes 3, 4, 5 & so on. There will also be a back button with reverse functionality. I'm guessing a for loop?This loads the correct indexes the 1:st time.[code]...

But my problem is when clicking the buttons - how do I add and subtract from the var i? The problem is also when reaching the end & there might be just a single post or so instead of 3 - how can all of this be solved? Or does anyone now of a tutorial similar to my problem. I've found some tutorials but they only deal with one post at a time...

View 2 Replies

ActionScript 3.0 :: Matching Array Indexes During Events?

Mar 7, 2012

This is a somewhat modified excerpt of code I'm trying to implement:

Code:
public class View extends Sprite
{

[code].....

View 6 Replies

ActionScript 2.0 :: Loop Through An Array Where The Indexes Are Literal?

Aug 17, 2003

Code:
ahmed = []
ahmed["a"] = "sdf"
ahmed["b"] = "asd"
trace(ahmed.length) // outputs 0

[Code]...

a) Why does the first piece trace 0 instead of 2?

b) How would i loop through an array where the indexes are literal (not numbers)

View 6 Replies

ActionScript 3.0 :: Access Multiple Array Indexes Simultaneously?

Apr 30, 2009

Is there a way to do something like this?

PHP Code:

var myArray:Array = new Array(10)
myArray[8, 9, 10].visible = false

where myArray[8, 9, 10] would access the last three objects referenced in the array?

View 6 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 3.0 :: Calculating Even Numbers In An Array?

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

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 :: Loop Through The Array Of Scores And To Check The Distance To Each Other?

Aug 19, 2011

In my game there appear scores when you shoot down enemies. That kinda works so far but they overlap when the enemies were too close to each other when shot down.Now what I'd like to do is to prevent the overlapping of the scores. The basic idea I had was to loop through the array of scores and to check the distance to each other.

Code:
private function checkScoreDistance():void
{
scoreManager.scoreCount = scoreManager.scores.length;[code]........

View 2 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

Arrays :: Count Only Set Indexes Using Loops

May 19, 2011

In PHP you can do something like this:
Array1 = 0,0,3,6,6,6,7,8,8,9

Then loop through Array1 and set the keys of Array2
Array2[0] = true;
Array2[3] = true;
Array2[6] = true;
Array2[7] = true;
Array2[8] = true;
Array2[9] = true;
Array2.count = 6;

But doing a similar thing in AS3 would result in a count of 10 (true,,,, true,,,, true, true, true, true) as all of the keys that are not set are counted. Is there a way of doing this without using any more loops? or Functions, simplicity and efficiently are important here.

View 1 Replies

ActionScript 3.0 :: Automatically Reversing Child Indexes?

Feb 9, 2009

I have to reverse the display order of a number of MovieClipsin a container. Somehow I cannot figure out how to do this as whenI use a loop construct and count through all Children I will always"pre"-alter the Indexes of the children still to come.

View 1 Replies

ActionScript 3.0 :: Sorting Multiple Arrays At Different Indexes?

Aug 5, 2009

I just have another really quick question about Arrays, this time about Sorting them. I have just re- written my code to work for matching values from 2 arrays and then adding them to the screen.
 
however it seems as my matching is way off, it matches the items that are at the same index, which is not always the case
 
The output for the matches, which should be side by sideis as follows (which is incorrect) Therfore i am trying to find values at diffrent index levels
 
DunlopbabolatWilsonwilsonHeaddunlopAdidasheadBabolatslazengerSlazegerprincePrincevolklVolkladidas
 
I tried to sort the Array, but it seems as though the array, cannot be sorted the way i want it. I simply wanted to sort it Acending, but changing it to lowecase would not do what i needed it to do.

This is the code, matchInfo function should do all the work

package {
import flash.display.*;
import fl.transitions.*;
import fl.transitions.easing.*;

[Code]....

View 8 Replies

ActionScript 3.0 :: TextField.setTextFormat() Doesn't Read Indexes In Cs5.5?

Aug 30, 2011

I have a TLFTextfield, which I've applied a TextFormat to, using a start and end index so it only applies to a range of text.Something similar to this:

var textfield:TLFTextField = new TLFTextField();
textfield.text = "Some Text";
textfield.textColor = 0x0000FF;

[code].....

View 2 Replies

ActionScript 3.0 :: Length Property - All String Indexes Are Zero Based

Sep 30, 2009

I am looking at "length" property in the Adobe AS3.0 language ref as I do not understand it. It says: An integer specifying the number of characters in the specified String object. (I understand this). Because all string indexes are zero-based, the index of the last character for any string x is x. length - 1. (I do not understand the "- 1". I understand that all string indexes are zero-based but I cant put this together with the last character for any string being -1 or whatever it is saying.

View 7 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

Professional :: Calculating Progress Bar Size?

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

Actionscript 3 :: Convert Calculating Result To Int In It?

Mar 26, 2011

Count = "400"/3 - 1;

How to convert the above count to int?

View 2 Replies

ActionScript 3.0 :: Calculating Positions Along A Curve

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

ActionScript 2.0 :: Calculating The Future Cost?

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

ActionScript 3.0 :: Calculating X- And Y-pos On 'circle-line'?

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

ActionScript 3.0 :: Calculating Parabolas For Projectiles?

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

ActionScript 3.0 :: Calculating JPGEncoder Quality?

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







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