ActionScript 2.0 :: Returning The Position Of An Element In An Array?

May 11, 2011

I've got an array (called "thearray") that I've just sorted alphabetically using thearray.sort.I then wanted to check if a certain item (myItem) was in the array, so I did a loop:

for (var w=0; w<thearray.length; w++){
if (thearray[w]==myItem) trace("this item has been found in the array")

Now, I want to know if it's possible to return the new position number of the item in the array - ie finding the element number of myItem (as in arrayelement[0], arrayelement[1], arrayelement[2]-- the number in the [ ].)

View 1 Replies


Similar Posts:


ActionScript 3.0 :: Getting The Position Of A Certain Element In An Array?

Dec 24, 2010

1. let's say I have an array full of mcs, is there a fast way of knowing the position of mc_b in that array without looping through it every time?

2. also, is there a fast way of swapping the position of two elements in an array without splitting it and re-sticking the parts?

View 8 Replies

ActionScript 3.0 :: Create Dynamic Array Element Names Based On Another Array?

Jun 28, 2009

Is it possible to, if you have an array of class names like ActionScript Code: var city01names:Array = ["pic_01", "pic_02", "pic_03" ...] make a new array which would read these names, instantiate them, and push them into a new array containing the instances of all these pictures, which I could then use for a slideshow?

[Code]...

View 7 Replies

ActionScript 2.0 :: Array Text Into Textfield And Creating New Line For Each Array Element?

Oct 4, 2006

I have an array called dropTarg1 which stores dropped-in items.I want to loop through this array and in a textfield, display each array item on a new line of this text fieldI think I need to use something like Array.join("/n") but I can't get it working properly. I hope that the /n would create a new line of the text field called reviewBoxContentText.

for(var i:Number = 0; i<dropTarg.length; i++){
with(reviewBoxContent.reviewBoxContentText){
autoSize = true;

[code].....

View 2 Replies

Flex 4 : Change Element Position In A S:List?

Dec 20, 2011

I have a s:List in my flex application attached to an ArrayCollection ( elements ). I want to change position of one element, so in fact I'm changing it's item index, the question is, how to do this kind of action ?

Here is a better example :

item 1 i : 1
item 2 i : 2
item 3 i : 3
item 4 i : 4

[Code]...

View 2 Replies

ActionScript 2.0 :: Adding A Element To An Array With Array.push

Mar 14, 2005

I have 4 buttons and an empty array. When a button is clicked,I'm adding a element to an array with array.push. However, I want to check the array 1st to see if that element exists. If so, then don't add it. Here's what I have thus far

[Code]...

Now I'm taking it I'd have a conditional statement to see if the element already exists. Unfortunatly I cannot just disable the button. I searched the AS dictionary but oddly enough it doesn't have an easy way to search an array. And IndexOf seems to only work for a string.

View 3 Replies

ActionScript 1/2 :: Returning The Minimum Value Of An Array?

Jan 16, 2010

how can I output the lower value inside an array of numbers? I have this but it is not doing the work, it is always returning the very first number in the array.

[Code].....

View 2 Replies

Actionscript 3 :: Returning Array In A Class?

Nov 5, 2009

I built a class that parses JSON data, stores it in an array, and now I want to return that data so that it can be stores in an array in my root AS file. I'm eventually trying to pass the returned array to another class. My class looks like this:

package com.src
{
import flash.display.Sprite;
import flash.net.URLRequest;

[Code]....

I keep getting the following error however:

1061: Call to a possibly undefined method payload through a reference with static type com.src.DataGrab.

Does anyone have advice on what might be wrong with my class, or a more logical way to write the getResults() function so that I can get retrieve the array being generated by this class?

View 2 Replies

ActionScript 2.0 :: Returning XML Data Into An Array?

Dec 2, 2009

I've been trying to figure out what I'm doing wrong here. I the below code works, but I want another function to be able to use the data stored in the 'sectionPathes' array.

How can I 'return' this data, so that other functions/etc can use it.

[Code]...

View 2 Replies

ActionScript 3.0 :: Get The Position Of The Last Element In A TextField With HTML Text Inside?

Jul 3, 2009

I need to get the position (x,y) of the last char in a textField with html text inside. I try with numlines and getLineMetrics, but that only work for non-html text. If I have a text like

Code:
<p>text one</p><p>This is the other text</p><br><br>

I need to have the position on the stage of the last "t".

View 4 Replies

Flex :: Assign An Array Element To Another Array

Aug 29, 2011

I have this array:

[Code]...

I want another array which takes the values of the price from the 1st Array. Can we do something like this? private var another_price_array:Array = [all_array.price]; This second array will be used to populate a ComboBox, or can I populate the combo directly from the first array itself?

View 2 Replies

ActionScript 3.0 :: Returning An Array After For Loop Has Finished?

Jun 15, 2009

I'm wondering how I can return the value of an array that is being created inside a for loop?I have created a class that is using ZendAmf to grab page titles out of a database. After the connection is made I put the page titles into an array with a for loop. I would like the class to return the value of the completed array.

I have tried using a public array variable and a getter, but I'm never going to get the correct value until the for loop finishes. So how would I go about getting the array variable after the loop has completed?I'd rather not set a listener that listens for a boolean inside the for loop.

View 6 Replies

ActionScript 3.0 :: Array Not Returning Text Fields

Nov 21, 2010

The code is coming up with [Text Object] instead of what the text actually is (and if I actually add .text it calls up absolutely nothing). This functions perfectly well when using the standard array without the sub-properties and {} brackets (so I think the problem might be somewhere in the push statements). I am not understanding what the error is (probably something blatantly simple, my only guess being some sort of conversion problem).

[Code]...

View 4 Replies

Flash - For Loop Only Returning Last Item In Array?

Nov 25, 2009

In a nutshell, I have a for loop updating a dynamic text element but it seems to iterate so fast that only the last item in the loop is updating the text. I'd like the dynamic text element to be updated with EACH item in the loop, not just the last.I have a single frame movie where I create a simple array of strings from an external text file:

_global.i = 0;
_global.numplaces = 0;
_global.PlacesArray = new Array();

[code]....

The traces work fine and show that the for loop is iterating properly. However the place.htmlText dynamic text in a movie nested one level down (for tweening purposes) that I'd like the loop to update is only updating with the last item in the array.

View 4 Replies

ActionScript 2.0 :: Array Returning Non-repeated Numbers?

Sep 19, 2006

Simple. Take the array [4,6,6,7,8,8] for example.we have the number 6 and 8 twice.Isn't there a method to return this array like: [4,6,7,8] ?or, how can I push this number into the array only if they are not pushed yet?I tryed to make a loop with condition to check if the numbers was already there, but I had no bliss.this is my code now:

HTML Code:
meses = [];
arquivos = xmlData.firstChild.childNodes[0];

[code].....

View 5 Replies

ActionScript 3.0 :: Flash Returning An Array From Within Class?

Feb 24, 2011

I have this class that basically reads a json file and then places it into an array, which I then want to pass back to the var set etc, how do i go about this:I have the following at present:Heres part of my list class:

Code:

... the normal import etc of stuff above then the following....
public function loadVideoList(_videoURL:String=""):void
{
try{

[code]....

View 4 Replies

Actionscript 3 :: Change Element Position Inside MovieClip In Event.RESIZE?

Oct 21, 2011

I have some little listener.

stage.addEventListener(Event.RESIZE,rozmiar1);
function rozmiar1(e:Event):void
{
ofertaBTN.oCenter.width=(14.59*stage.stageWidth)/100;
ofertaBTN.oRight.x = ofertaBTN.x+ofertaBTN.oLeft.width +ofertaBTN.Ocenter.width;
}

But only ofertaBTN.oCenter.width is changing. oRight is not responding and I get error #1010.

View 1 Replies

ActionScript 3.0 :: Sorting An Array Of Objects And Returning Another Variable

Aug 29, 2011

I have an object array into which I've pushed a number of objects with different variables :- myArray.push({myRef: 1, myValue: "W"}); I can sort the array in numerical order using :-myArray.sortOn("myRef", Array.NUMERIC);but after sorting I would like to collapse the array using something along the lines of :-myArray.join("");to join the OTHER variable (myValue)...Is it possible to do this without pushing every instance of 'myValue' to another array and then joining that?

View 4 Replies

ActionScript 3.0 :: Returning Incremental Difference Between Values In An Array

Jul 15, 2009

I'm making an activity that involves measuring the depth of a fictitious river at various points. I have an array containing those depths at the various points and a slider for traversing through the depths and outputting to a textfield.

As the user moves the slider up and down, they can see the depth of the river at that point and plot it onto a graph. What I would like to do is be able to figure out the depths inbetween the explicitly defined values.

here is the code, it's pretty simple:

[Code].....

How would I go about figuring out the values inbetween?

View 2 Replies

Actionscript 3 :: Detect Element Transformation Type For Rotated Elements Depending On Cursor Position?

Feb 2, 2010

I've written the following method (in actionscript 3, it's a flash application) which returns what transformation type is required for the current mouse position in relation to a given element position.

An element can be moved, scaled and rotated. This method returns if any of these transformations are applicable with the given coordinates[code]...

View 2 Replies

ActionScript 3.0 :: Split A Large Text File Into An Array At Line Breaks So One Array Element = One Line?

Jan 8, 2010

i need to split a large text file into an array at line breaks so one array element = one line.i have tried the using "" in both match() and in RegExp but it doesnt work.i had the g and m flags on. tried the $ sign too.

View 8 Replies

ActionScript 3.0 :: Get Array Position Of Clicked Item To Fetch String From Another Array?

Mar 23, 2010

I put my mc's in an array.I have another array with strings.when the mc is clicked I want to get its position in the mc array and return the string from the same position in the string array.How do I do that?

PHP Code:
var numBtnArray:Array = new Array;
function addNumButtonsToStage():void{

[code].....

View 4 Replies

ActionScript 3.0 :: Get One Element From The Array?

Dec 28, 2011

I know how to get one element from the array. But I don't know let's say how to take 3 elements ( position 0,1,2). I don't know how to trace all the three together. I am getting errors all the time.
 
var myArray:Array = [1,2,3,4,5];
trace(myArray[0]); 
trace(myArray[0], ?,?);

View 3 Replies

Flex :: Get An Array Element?

Aug 18, 2009

I have an array like this

public var dataAL:Array=[
{Kiv:"cash", jan:26,janTarget:28,feb:27,febTarget:26,mar:30,marTarget:32,apr:31,aprTarget:32,may:28,mayTarget:29,jun:46,junTarget:32,jul:37,julTarget:39,aug:40,augTarget:42,sep:41,sepTarget:42,oct:48,octTarget:49,nov:40,novTarget:41,dec:38,decTarget:40},

[code]....

Now if i want to access febTarget for cash how will i do it?

View 1 Replies

Flash :: Add Element To Array?

Jul 10, 2011

How can add element to array in ActionScript3

If i have an array: var myArray:Array;

How can add element to this array "myArray", something like this:

myArray[] = value;

My second question is: How can compare if variable value exist in array element value?

Something like in_array function in php

View 3 Replies

IDE :: Show One Array Element For 1 Sec?

Apr 14, 2009

I'm trying to make a memory like game. It might be called Simon or Simple Simon or something. Basically something is shown for a second and then gone, then the user clicks that something. Then two or three things are shown in order and then gone and the user clicks the order.

I'm stuck at the very beginning, just showing something from an array for half a second or so then stopping and then starting over and adding one more element.

View 4 Replies

ActionScript 2.0 :: Add Element To Array When It Is Not In There Already?

Jun 22, 2010

This is for a small RTS prototype I'm working on for some fun, but I've hit a snag.

For examples sake, I've got two arrays, activeAgents and houseArray. A number of movieclips (player controled units/agents) are stored in activeAgents and houseArray is used to store any agent that is "inside" the house.

If an agent in activeAgents hitTests the house that houseArray belongs to and the agent ISN'T already in the houseArray, then I want to add the agent from activeAgents INTO the houseArray.[code]...

View 1 Replies

ActionScript 2.0 :: Set Something To The VALUE Of An Element On An Array?

Jun 19, 2011

Code:
arrayA[i] = arrayB[j];
This results in:
1:[object #7, class 'Array'],

I'm would like to set arrayA[i] to the value of arrayB[j], not set arrayA[i] to the object arrayB[j].

I can't use .toString() as I'm trying to pass on an array inside an array.

View 1 Replies

ActionScript 3.0 :: When Run Get LastIndexof For Array / Get Returned Size Of Array Instead Of Position

Aug 11, 2011

when i run get lastIndexof for an array I get returned the the size of the array instead of the position here is the code:[code]but instead of returning the last index of it before the current index, it returns the current index (or jus the array length). help!!! it is my first time using lastIndexOf so I am probably using it incorrectly.ps this does not include some of the function run (i know i am passing a value which it does not look like i am using, but i know that part of the code works)

View 5 Replies

ActionScript 2.0 :: CS3 Remove Element From Array?

Jun 16, 2009

I have an array used to track shots fired from a cannon, and when they hit the ground they are removed.

I would like to know what is the most efficient way of finding and removing a certain element from an array. I heard that using pop() instead of splice() was faster, is it ?

Also, the big question I have is that the only way I see of actually finding the element in the array is using

Code:
for(i=0;i<array.length;i++){
if(array[i] == movieClipToRemove){
//i == movieClip index in the array
}
}

Then I would use either splice() or pop() to remove it from the array before deleting the MC. Is there a better way than scanning through the whole array comparing each element to the triggering MC ?

View 2 Replies







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