ActionScript 2.0 :: Making Algorithm Using Two Arrays?

Jul 25, 2008

I am programing with AS2 so here goes my question: I want to create an algorithm that looks up an array and finds the nearest integer in it. Lets say i have different numbers like 1, 2, 4, 5, 8, 9 and i want to find the nearest member to 6 from those numbers. How should i build the algorithm. So far i'm using two arrays and two inside loops, but cant find the right way to make it.

View 3 Replies


Similar Posts:


AS3 :: Algorithm - Total Count Of Merged Similar Sub Arrays

Nov 5, 2011

I've got what should be a simple problem I can't quiet get my head around: Say I have these array values (could change, but same basic structure):

[Code]...

The sub array could go deeper, or it could be less, but it's always a matter of comparing within the subarray to get the goal. The answer I'm after is a count of total matched groups. So since there is a 4 and 3 together all 4 and 3s would simply count as a 1. My expected result from the above would be 3 (a count of total unique groups). All the 0s are 1, all the 3 and 4s merge together to be 2 and the 6 are 3. I just care the value is 3.

View 1 Replies

Actionscript 3 :: Creating Algorithm For Making Ternary/Triangle Plot Graph?

Oct 14, 2010

I have a need to create a Ternary Plot graph from 3 different variables.

[URL]

I basically need to come up with the x/y coordinates of the point within the triangle, from the ratio of the 3 variables.

Is there any function / algorithm that anyone is using to create this? The language I am using by the way is ActionScript 3

View 2 Replies

ActionScript 3.0 :: Targeting Arrays And Making Them Invisible?

Jul 23, 2009

I'm having trouble targeting elements of an array using AS3. I have five buttons in an array named botons.
 
var botons:Array = [boton_1, boton_2, boton_3, boton_4, boton_5];
 
Each button goes to a different page, but they all are on the same layer like navigation bar. When page 1 is visited button 1 should be invisible and the others visible. When on page 2, button 2 should be invisible but all others visible.
 
I used the following to make the entire array invisible and it works.
 
for(var i:int; i<clips.length;i++){botons[i].visible=false;}
 
How can I make each button invisible when visiting its page, but make the rest visible?

View 8 Replies

ActionScript 3.0 :: Targeting Arrays And Making Them Invisible

Jul 25, 2009

I'm having trouble working with buttons in an array. I would like to target specific button and make it invisible while the others remain visible. Each buttons goes to a page (first, second, third, etc.). There are five buttons named button1... button5. I'm using AS3 in timeline.

Problem: when I click a button, it doesn't get invisible and I get this message:
TypeError: Error #1009: Cannot access a property or method of a null object reference. at subtraction_fla::MainTimeline/goPNext()

Here is my script:
stop();
var button= [button1, button2, button3, button4, button5];
button1.addEventListener(MouseEvent.CLICK, goPNext);
[Code] .....

View 6 Replies

ActionScript 2.0 :: Making A Multiple Row Menu With Arrays?

Sep 18, 2007

I'm trying to make a navigation of sorts using a bunch of thumbnails there will be 3 columns and 3 rows.I have made an array of images, created a button with an empty movie clip in it. And I am attempting to make a 3 by 3 grid of buttons based off the array... Here is my code.

cubicThumbs = ["Bracelet_Nugget_1_thmb.jpg","Earring_Nugget_1_thm b.jpg","Necklace_Nugget_1_thmb.jpg","Earring_Nugge t_1_thmb.jpg","Necklace_Nugget_1_thmb.jpg"];

[code].......

View 1 Replies

Arrays :: Flash - Pushing Or Adding Arrays As Values Into A Multi-dimensional Array?

Jan 21, 2011

I am running into some trouble adding an array into another array to create a multi-dimensional array.The code appears as below:

var slideDataArray:Array = new Array();
var slideShowDataArray:Array = new Array();
slideDataArray[0] = xmlData.SlideShowParameters.SlideShowImagesDirectory;[code]........


I am looking for a means of placing the slideDataArray into a 'slot' or value of slideShowDataArray so that I can in the end pass the slideShowDataArray as a parameter to another function.As of now, the last slideDataArray appears 11 times (the loop runs 11 times) in slideShowDataArray and the way the code is written the slideDataArray is unique every iteration of the loop.

View 1 Replies

ActionScript 3.0 :: Arrays Of Arrays / Data Providers And Dictionarys

Aug 26, 2009

I've got a bit that loads a big chunk of xml data about products.I push product info into an array(e.g. productArray), then add that array to another array (e.g. allProductsArray)How do I sort those arrays? For instance, if I want to sort the allProductsArray based on the info in productArray[0]?Alternatively, would something other tha an array of arrays be a better route?This loader loads the same sort of info for many different clients, so the bit to sort on will change.

View 5 Replies

Actionscript 3.0 :: What Algorithm I Should Use?

Dec 20, 2010

[flash=]
package app.demo.MyTouchApp{
import flash.display.Sprite;[code]..........

how to perform a search in XML, so I use the above method, kinda hard code I know...for example, I try to search " keyIn:String = "BR1014"; " means I wanna search BR1014 in 4 XML files, so I load the XML info into an array, and using for loop to loop the XML array (in this case TitleArray1[i], TitleArray2[i]...) and compare it with keyIn (which store the value BR1014), some how the value is located in TitleArray4[i] which have the length of 12 (trace(TitleArray4[i].length) = 12)

so everytime I run it, I will overwrite abc 12 times... and out put 12 time the abc value, in this case BR1014 was located in TitleArray4[3], so the 4th output of "abc" is BR1014 but others is all 999...

View 2 Replies

ActionScript 2.0 :: Crossing Algorithm?

Jun 4, 2011

I have table

words = [aaaa, bbbb,cccc,dddd,eeee,ffff]
and i want to make table like this:
words2 = [aabb,bbaa,ccdd,ddcc,eeff,ffee]

View 1 Replies

Sql :: Realization Of An Algorithm In SQL Query?

Dec 14, 2011

I have a database which has 2 tables:

CREATE TABLE RecipeDB (
RecipeID INT PRIMARY KEY AUTO_INCREMENT,
Name VARCHAR,[code]........

I also have an actionscript, in which I have ingArr:Array of ingredient strings.Now, I would like to realize the following queries here:

1) Select (all fields) one recipe which has the most of ingredients from the array. If more than one record have the same amount of matches, then divide the number of matches by total number of ingredients in recipe and return the one with the highest ratio. If there are no matches return nothing.

2) As above, but return 10 recipes with the most matches and do not perform check for equal number of matches. Sort the results by the number of matches.

View 2 Replies

Arrays :: Fastest Way To Merge Multiple Arrays?

Sep 26, 2011

I'm trying to write a function where I can specify any amount of array, and the return value will be an array containing the contents of all of the specified arrays.I've done this, but it seems like a really slow and ugly way of doing it:

var ar1:Array = [1,2,3,4,5,6,7,8,9];
var ar2:Array = ['a','b','c','d','e','f','g','h'];
function merge(...multi):Array[code].....

Is there an inbuilt and more efficient / nice way of achieving this? The result does not need to be in the same order as the input - completely unsorted is fine.

View 3 Replies

ActionScript 3.0 :: Randomizing The World! Arrays And More Arrays?

Feb 17, 2009

A little explanation: Im making a random arranging number Array. So instead of using a loop and assigning 0 to first array element, 1 to second, etc.I need to make it totally random but without repeating any numbers. To do that I made a second Array that will have the same number of children to serve as a reference.Each of them will be an Object with a property "num" , wich will be its actual number, and a property "called" wich defaults to false.Like this:

ActionScript Code:
for(var i:int=0;i<vQuantity;i++){
ranArray.push( new Object() );

[code].......

View 8 Replies

ActionScript 3.0 :: Arrays Store References Of Other Arrays?

Dec 27, 2009

I've had a problem for awhile that was really odd. After some intense debugging, I realized the problem lied in setting an array equal to another array.[code] When setting one array equal to another, the values aren't copied over, but a reference to that memory is stored. So no matter which variable you change, they are both references to the same memory and thus both will reflect the changes.With other data types, this doesn't happen.I could fix it by looping through t1 and using push() to add each index from t1 into t2, but that seems a little messy.

View 7 Replies

ActionScript 2.0 :: Pushing Variables To Arrays Within Arrays?

Jun 25, 2004

correct syntax for pushing variables to arrays within arrays? I have searched many threads but found nothing that exactly answers my query.I have a class (Brigade) which amongst other variables contains an array (BrigadeUnits) This is the third element.. My Brigades are stored in an array called AllBrigades. I now need to fill the BrigadeUnits array with objects of my Units class.The hierarchy I want to create is as follows:

AllBrigades (array of Brigades)
Brigade (object)
BrigadeUnits (array within Brigade object)
Unit (Object to be stored in BrigadeUnits array)

I have tried various approaches including the following, assuming that I am addressing the first Brigade in the array:

AllBrigades [0] [2].push (MyUnit);

But when I trace this I just get undefined.

View 14 Replies

ActionScript 3.0 :: Algorithm - Stimulate Sea Wave

Dec 15, 2011

I want to stimulate sea wave,but I have no idea about it. Is there an example code for it? I know as3 can make many good graphics and text effect, so I want to learn it eagerly,but I don't know which book should I read. Anyone could introduce a good book for me about as3 algorithm? More example code are better in the book.

View 3 Replies

Java :: Sha Or Md5 Algorithm Encrypt And Decrypt?

Feb 25, 2010

I am developing my application in flex and JSP, so when I am passing values through HTTP Service Post method with request object but these values are tracing and modifying by testing team so I am planning to encrypt values in flex and decrypt it in jsp.so is there any algorithms like SHA or MD5 more secure algorithms,

[Code]...

View 4 Replies

AS3 :: C - Implementation Of Upper Power Of Two Algorithm

Mar 1, 2011

I have been trying to implement the Round Up Power Of 2 algorithm outlined in the following link in AS3.

[Code]...

The algorithm works great for most of the values I've tested. It is mentioned that this will return 0 when given an input value of 0 which is technically incorrect but I'm ok with that output. What I'm not ok with is when given an input of 1 I get and output of 1. I'm thinking that this must be a caveat of AS3 and its wonky uint implementation but I can't seem to figure it out. I have also tried using the >>> logical shift operator to the same result. My C is a little rusty, but I'm not sure how this would even return 2 in C. Can someone explain to me whats going wrong here? I assume if an input of 1 was a special case it would have been mentioned in the above link.

View 1 Replies

Flash :: Erase Algorithm To Be Implemented Using AS3?

Jun 10, 2011

Is there any algorithm to perform erase operation in a bitmap? I would like to create functionality similar to how photoshop or other graphic application performs erase. Is erase operation so difficult that there isn't much help (for bitmaps) available? I am OK even with name of an algorithm, I can proceed from there.

View 2 Replies

Flash :: Algorithm To Create Concertina?

Sep 12, 2011

I've searched and racked to no avail.. so, does anyone have an algorithm to create a concertina type rectangle, ideally horizontally. The desired effect is exactly like that of normal horizontal Window Blinds (assume they're closed- doesn't matter) of say 30 parts (or slats) of equal height and uniform width.

When such a blind is raised half-way up notice how the parts at the bottom go from dead flat to an increasing value in height, with perhaps the top-most part hanging normally.

Similarly, when the whole Blind is all the way up, all parts are flat. Conversely, when the whole Blind is fully extended, all parts hang at their own, uniform height. It's this "slightly differing but related to my neighbors height" I'm stuck on.

View 1 Replies

ActionScript 2.0 :: A Algorithm Of The Number's Sequence?

Dec 13, 2004

how to implement this algorithm: I have number (1-100), however, it will return to 0, when it meets 10, likewise 11 returns to 1, 12 to 2...

90 -> 0
91 -> 1
...

View 3 Replies

ActionScript 3.0 :: Button Animation Algorithm?

Apr 26, 2008

I have 5 Button movieclips, each with different states, (OVER, OUT, and ACTIVATED)Obviously when you rollover the button, itll play the over animation, itll also apply for the rollout event of the button. When you click the button, itll go to the activated state.Here's my question...What condition will i use so that when a certain button is activated and i click on a different button, the activated button will play its rollout state before going to its idle state.. What's happening to me is itll just quickly go to its idle state without playing his roll out animation.

View 8 Replies

ActionScript 2.0 :: Cyclic Algorithm In Flash

Jun 5, 2004

my program calculates ax,ay -> using this variables -> vx,vy -> after that I calculate the little step that my mc will make, in other words I calc x,y position [code]as you can see all depend on each other...but the problem is that after getting new x,y I want this x,y to be used to calculate next step!fo every new coordinate I want new vx,vy ax ay!

View 8 Replies

ActionScript 2.0 :: An Algorithm Of The Number's Sequence?

Dec 13, 2004

I met a problem while I am learning the flash actionscript 2.The question is how to implement this algorithm: I have number (1-100), however, it will return to 0, when it meets 10, likewise 11 returns to 1, 12 to 2...

90 -> 0
91 -> 1
...

View 3 Replies

Flash - Get Shortest Number Algorithm In AS Syntax

Apr 15, 2010

I want to put shortest int in shortest:
shortest = 500;
for(i = 1; i <= _global.var_process_count; i++) {
if(_root["process" + i].process_time_original.text < shortest)
shortest = _root["process" + i].process_time_original.text ;
}
What's wrong with above lines of code?

View 1 Replies

Actionscript 3 :: Implement SHA1 Algorithm In Flex?

Dec 9, 2010

I am building an application in Flex, wherein I need to encrypt user id and password using the SHA1 alogorithm. I have not come across any standard Flex library which allows me to do this. Does anyone know how to achieve this in Flex?

View 1 Replies

ActionScript 3.0 :: Manage The Depths Of The MCs Was A BubbleSorting Algorithm

Feb 5, 2009

I'm currently working on side scroller that has an isometric-type perspective (think Double Dragon) and the only thing I could think of to use to manage the depths of the MCs was a bubbleSorting algorithm.

[Code]...

Now this works fine (because I don't have a huge amount of MCs to sort), so I guess this is more of an academic question. As far as I know, bubblesorting is pretty much one of the worst sorting algorithms out there. Has anyone successfully adapted a better one for this purpose? Not trying to get you to post your code as much as just an idea for me to play around with because I'm a geek like that.

View 0 Replies

ActionScript 3.0 :: Linked List Sorting Best Algorithm?

Dec 26, 2009

I know there isn't a built-in linked list in AS3, but one can easily write his own. However, I found it difficult to come up with a good solution for sorting such list.If you didn't know, linked list is a chain of "cell" objects, where each object has a reference to the next object, typically you can write it like this:

Cell1.next = Cell2;
Cell2.next = Cell3;
CellN.next = null;

(Circular linked list and bidi linked lists are out of the scope of my problem, for now at least).

I looked into other languages that do have linked lists or even standard libraries for them, however, I don't seem to be able to either port any of their solutions, or, some of them, if ported to AS3 would not be workable (since they use recursion) or would otherwise have huge overhead because of lots of method calls etc.

I think, I'm focused on 2 possible algorithms: Merge sort and Insertion sort. These two seem to be most applicable to AS3. However, I may be wrong - so, please fill free to correct me.

View 5 Replies

Actionscript 3.0 :: Good Algorithm To Move Along A Path?

May 17, 2009

I have finished a little game called "math match". The idea of the game comes from "math mountain", a game is for the player who must caculate some kind of mathmatic questions, if the answer is correct, the player will move along a predefined path in several steps. I am newbie for programming games, so I am not sure what I have done in moving the role is the correct one, although it works okay. I know in Flash CS3, I can use motion guid layer to make the role move along a predefined path, but it seems it's not good in the game, or I don't know how to control it in actionscript 3.0. So I used many 'marks'(little movieclip) along the path. That divide a path into small pieces of lines, so I can move the role along the lines. If the 'marks' is enough, the precise is enough, the movement works okay.

But I think it's quite not a good method. I don't know if there is any good algorithm to move the movieclip along a predefined path, and this path is random, is hardly to be described by any math equation. I think in Flash CS3, we can draw a path by author tools, indeed Flash CS3 use some algorithm to do that. If we can get that math equation, we can simulate the movement very precisily, but is it possible? I don't know.

View 7 Replies

ActionScript 2.0 :: Mod-10 Number Validation Algorithm (modulo 10)

Jul 22, 2005

I'm looking for a Mod-10 (modulo 10) validation algorithm writen in actionscript. From a text-field, the user will enter a code and on submit, actionscript will validate if the number is right.

View 3 Replies







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