ActionScript 3.0 :: Recursive Array Searching Optimisation?

Apr 25, 2010

I'm working on a grid based game where a user selects a tile and all the tiles with the same colour that are beside it disappear. Up until now I've been using this very rudimentary method to find the neighbouring tiles with the same colour (see below) but now that the game has gotten more complex and larger grids are involved performance is starting to lag so I optimizing the code. have a Tile class like this:

Code:
package {
public class Tile {

[code]....

View 6 Replies


Similar Posts:


Flash :: Use Of The Array.filter() Method For Searching And Retrieving An Object Instance From An Array?

Jul 13, 2010

I am curious if this is an okay implementation of the Array.filter() method.

[Code]...

I was not able to figure out an implementation of the callback function for the filter() method, where the callback was outside of the getGallery() function. I wonder if there is a way to get the isGallery function outside of the getGallery scope?

View 1 Replies

ActionScript 2.0 :: Recursive XML To Multidimensional Array

Dec 27, 2010

ActionScript Code:
<root>
<node>

[Code].....

create Multidimensional Array from Recursive XML.

All I need create Array inside an Array dynamically from an unknown XML tree.

View 3 Replies

ActionScript 2.0 :: Recursive Array On Levitated.net?

Nov 4, 2004

I've been studying the experiments on Levitated a lot. I've been looking over this one that deals with recursive functions. Here is the link:The actually get most of it. There is one part with an array though that pushes something and I don't understand it. Here's the code:

Code:
function addFillRequest(x0, y0, x1, y1, d) {
// que up a request to fill a region

[code].....

View 5 Replies

ActionScript 2.0 :: Searching Through An Array Generated From A XML

Jul 6, 2009

I'm working with tons of array generated from a XML. How should I go about creating a search function that will be able to search and retrieve a particular nod from the array. Sth to do with .toLowerCase() and getIndexOf? The search function should be able to search and retrieve any text that contain the letter/letters... not the whole word. Like for example if user enter "gre", it should retrieve results containing "great" and so on.

View 1 Replies

ActionScript 3.0 :: Searching Through Array Of Objects

Aug 12, 2009

I have got an array of objects, each with properties, plus those objects have sub objects.

Example
Code:
Array[0]
Object.id = 0
Object.name = fish
Object.Array[0]
object.id = 0
object.variety = red tetra
[Code] .....

So now it will go through every item in the array and work filterArray on it, but where to proceed from here?

View 4 Replies

ActionScript 2.0 :: Searching For Keyword In Array?

Apr 9, 2010

How can I search for a keyword in an array?

View 3 Replies

ActionScript 2.0 :: Searching In Array With Objects

Mar 15, 2006

[Code]...

Does anybody have an idea how to search the strings in the array? Let's say the user types "ci" to the search field, searching in "taste" (it would be marked). Now it should return the objects which have the string "ci" in the taste, as: apple - acid - red berry - acid - purple..

View 1 Replies

ActionScript 3.0 :: Multidimensional Array And String Searching

Jul 20, 2009

I have one global array, and I am pushing other arrays (which contain strings) in it.
[GOLD, SILVER, BRONCE]
[BLUE, RED, GREY, ORANGE, PURPLE]
[JUICE, BEER, WATER, MILK, COFFEE]
[MERC, BMW, SUBARU, MITSUBISHI, TOYOTA]

Lets say I have these 4 arrays, and I push them into global array in that order.
Example 1:
if I have string "MILK", I need to search the global array and what I want is to pull out last array (with cars) because "MILK" is contained in third array (going from the beggining).
Example 2:
if I choose "ORANGE" I want to pull out last 2 arrays (drinks and cars).
Example 3:
if I choose string from the last array ("MERC") nothing is pulled out. And by pull out I mean just get to it.

View 7 Replies

ActionScript 3.0 :: Searching Through Array Of Complex Data Object On Specified Properties?

Sep 27, 2011

Is there any 3rd-party library on AS3.0( like STL in C++) around, can do this:I define my class and use its objects as associative array, for example:

class Company{
var public name;
var public logo;
var public address;
var public telnumber;
}

And use a kind of data structure class(say, List) to store a few Company-type objects. And then, I define my own comparing and searching function on that List class(namely, override the default one); within my functions I could specify on which attribute(name, or address, or telephone number) to perform searching, and how it would be performed.

View 4 Replies

ActionScript 2.0 :: Finding Values In Array - Searching Small Number Of Elements

Feb 3, 2006

I just read the tutorial "Finding Values in an Array". Sure, the code works, but that's only because we are searching arrays the contain a small number of elements. Suppose we have n elements in an array. To search that array for a particular element we may have to do n comparisons. If the array we are searching contains 10 million elements, we have a problem; can you imagine doing "if (this == that)" 10 million times? There's got to be a better way to search the array. Or perhaps we shouldn't use arrays to store the information.

View 9 Replies

ActionScript 3.0 :: Flash Enter Frame Events On Optimisation?

Mar 7, 2011

Lets say I am working on some basic shooting game that involves lots of moving enemies. The enemies all come from one class that extends movieclip.

I want the enemies to move 10px downwards every frame. At the moment I know of two ways of doing this:

The first is to run a single onEnterFrame function on the main timeline, this function loops through all of the enemies on the screen calling a function in the enemy class that contains "x+=10".

The second is to put the onEnterFrame function inside the constructor function of the enemy class that would then contain the "x+=10".

Both give the same result but is one less work for the computer than the other? The first has a big loop that accesses all of the enemies, the second has an "onEnterFrame" running for each of the enemies.

View 6 Replies

Professional :: Uses Multiple Swfs To Make Up The Game And Its Elements For Optimisation?

Mar 21, 2010

wonered if someone could help me wih this one. Currently making a facebook game all in flash, it uses multiple swfs to make up the game and its elements for optimisation.
 
My question really is down to flash cache issue so we can make updates to various swfs that are going to be, site wide for users so the game doesnt break. Currently some users get older versions which breaks things if other swfs have chnaged how they communicate as an example.
 
I am aware of adding a query string onto the end to force to get the latest version.....however doesnt this make the use of a cache redudant as its being simply overriden? Would jsut like it to work as it should:) If theres a new version of a swf use it..if not use current one.

View 5 Replies

Actionscript :: Recursive Function And Returned Value?

Nov 5, 2010

I think I have the recursion working properly, but I'm not able to get the originally requested item's property set to the right value.The goal here is to find the topmost parent (or "ancestor," depth = 0) of the nested item (a taxonomy based on Dictionary "parent" attributes), and assign that originally requested nested item's "ancestor" property accordingly.For instance, in

Apples
- Red
- - Empire
- - - Fresh

"Fresh"'s ancestor should be set to "Apples." While I'm attempting this on an "on-demand" and individual basis, I'm open to a solution that tags all children that are related to the same ancestor in one fell swoop or for statement, since that would probably be more efficient.

REQUEST

for (var mc:Object in taxonomy) {
var term = taxonomy[mc];[code]....

As you can see, while the recursion does find the root, the originally requested item still gets the default value.

View 2 Replies

ActionScript 2.0 :: Recursive Function XML Tree

May 3, 2004

im having a problem reading a xml tree in Flash MX...[code]and this Actionscript to just to view the tree.[code]meaning that when it calls itself again, that it will stop searching the next items on the same level from where it was called.how do i not let it stop searching and complete the tree.

View 4 Replies

ActionScript 2.0 :: Any Way To Determine Recursive Loop End?

Jul 4, 2005

How do I determine the end of a recursive loop - when going through an xml document of unknown size?

View 7 Replies

ActionScript 2.0 :: Recursive Limits Workaround?

May 11, 2007

I am making a SUDOKU generator(ActionScript2.0), which would (for now) generate the full and correct sudoku table. To do that I need to use recursive functions for calculating all the possible values. The problem is that when I try to run my program I get this error :

Code:

256 levels of recursion were exceeded in one action list.

This is probably an infinite loop.

Further execution of actions has been disabled in this movie.Is it possible to somehow work around this limitation?

View 2 Replies

ActionScript 2.0 :: Recursive Functions And Loops?

Jan 16, 2009

I'm trying to create a minesweeper game as exercise, but I stumbled upon a problem.I've cleaned the code for you so only the relevant code is here:

Code:
function expand(cell) {
getbounds(bounds,cell.row,cell.col);

[code].....

View 1 Replies

ActionScript 3.0 :: [flex As3]function Non Recursive Call. How?

Feb 3, 2009

So, I create standard AS3 flex project. In constructor goes only start();


rest of functions are basically this:

private start():void { f1();}

private function f1():void { f2();}

private function f2():void { f1();}


And it's standard recursion. SWF either breaks or loops as many times as I tell it. One f calls the other, which calls first... I do not want that.

I want f1 to do some stuff, calls f1 and closes itself. Than f2 works, calls f1 and closes. And so on.

Like having 2 sets of code that loops through.
What's the cleanest way to do that?

View 16 Replies

ActionScript 3.0 :: Recursive Function To Search Through XML Tree

Aug 27, 2009

I want to vreate a recursive function that will search through my xml tree and display all the leaves(node values); this is the function that I wrote:

function searchXML (theItem) {
trace("theItem.*.length() "+theItem.length());
trace("theItem.* "+theItem);
trace("--------------------------------------");
if (theItem.*.length() > 0) {
searchXML(theItem.*);
[Code] .....

View 1 Replies

ActionScript 3.0 :: [flex As3] Function Non Recursive Call?

Sep 2, 2009

I create standard AS3 flex project. In constructor goes only start();

rest of functions are basically this:
private start():void { f1();}
private function f1():void { f2();}
private function f2():void { f1();}

And it's standard recursion. SWF either breaks or loops as many times as I tell it. One f calls the other, which calls first... I do not want that. I want f1 to do some stuff, calls f1 and closes itself. Than f2 works, calls f1 and closes. And so on. Like having 2 sets of code that loops through.

View 1 Replies

ActionScript 1/2 :: Recursive Function Crawling Through Movieclips?

May 19, 2010

I have this function to find occurences of misstyped varaible names (with wrong lower / upper case). I have a movieclip called "debug" where I define and call this funciton ("getCase(_level0)"). But It never finds my testttt variable - If I put the test varaible in _level0 the variable is found. 
 
var targetsCase_ary:Object =  new Object();
var targetsLower_ary:Object =  new Object();        testttt = 1    testttT = 1        function getCase(clip:MovieClip, recu:Number){        if (recu==undefined) recu = 1;        var n:String;        for (n in clip){            var sPath:String = clip._target + "." + n;            var sPathLower:String = sPath.toLowerCase ();                        //trace(sPathLower + " " +

[code]....

View 3 Replies

ActionScript 3.0 :: Make A Recursive Button Event?

Mar 14, 2011

I have a menu of 4 buttons and I'm trying to not be redundant and recursively use the same over, out, clicked function for each button by passing it's instance through the event handler.

I haven't had a whole lot of success finding the answer except locating a thread about creating custom classes....Which would be great, but I don't want to re-create my entire structure now. So I was wondering what the best approach might be.

Here's the code I've been working on.

[Code].....

View 4 Replies

Flex :: Recursive Iteration Through Every Component Instance?

Nov 17, 2009

I have various custom component instances in my flex app. I want to loop through them recursively and get their instance Ids. The recursive part is very important to me. I have tried doing this, but it didn't do recursive:

for each (var myItem:* in this.MasterContainer.childDescriptors)
{
trace(myItem.id);
}

View 3 Replies

ActionScript 3 :: Slowing Down Loop In Recursive Function

May 2, 2010

I have a difficult problem with a recursive function. Essentially I need to 'slow down' a for loop within a function that repeatedly calls itself (the function); Is this possible, or do I need to somehow extract the recursive nature of the function?

function callRecursiveFuncAgain(ob:Object):void{
//do recursive stuff;
for (var i:int = 0; i < 4; i++) {
_nextObj=foo
callRecursiveFuncAgain(_nextObj);
}}

View 3 Replies

Actionscript 3 :: Recursive Folder/Directory Copy With Air?

Sep 13, 2010

Is it possible to use pause/resume function to this??

source.copyTo( destination );

It would be great if you can send it at the earliest.

View 2 Replies

AS3 :: Flash - Recursive Object Scan Without Repeats?

Jun 12, 2011

While recursive scans are commonly use to scan through nested objects / data. It can go on an infinite loop, if some of the objects references one another. So what is the most effective way to scan all items, without crashing the computer, nor skipping a specified parameter?

Here is an example of a recursive scanner...

/**
* Triggers the scan function for each object given
**/
function recursiveScanner( object:* , scanFunction:Function ):void {

[Code].....

The objects will trigger scans for one another in an eternal loop.

I do believe in C/C++ : Each scanFunction call, will be added into a list consisting of scanned 'memory address', thus preventing a repeat. Is this even possible in AS3? Is there a more elegent way?

View 2 Replies

Actionscript 3 :: Recursive Flex View Component?

Sep 15, 2011

I have a Flex component that is a view of a data Object that recursively has a reference to itself.

For example if you had an Employee class that references a boss field of type Person, I'd like to nest the same view for that Boss. This shouldn't be an infinite recursive relationship (e.g. I'd only be viewing the boss field of each object).

I've tried creating an MXML component that references itself but when I run it locks up (seems like it gets into a recursive loop).

Is there anything you can do like includeInLayout conditions that will make sure it doesn't even instantiate that component.

View 3 Replies

ActionScript 3.0 :: Adding Timer To Recursive Function?

Nov 16, 2010

I made an app (Towers of Hanoi) and i added a "demo" button that solves the problem based on a recursive function. The button is supposed to make a move one step at the time, i mean one step at every few seconds so you can actually see how the algorithm works. The problem is i haven't really used the timer event before and i have no idea how to implement it in this particular scenario.

Code:
function hanoiPlay(n:int,a:Stack,c:Stack,b:Stack):void
{

[code]......

View 7 Replies

ActionScript 3.0 :: Recursive Function Returning Null Value

Feb 7, 2011

I've been trying to implement a QuadTree to store a two-dimensional array representing a terrain. I generate the array first, then I use the below function to generate a QuadTree for the array.

[Code]....

View 5 Replies







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