Actionscript 3 :: Custom Sorting Function Bottleneck?

Jun 6, 2011

I am trying to sort big array using actionscript 3. The problem is that i have to use custom sorting function which is painfully slow and leads to flash plugin crash.

Below is a sample code for custom function used to sort array by length of its members:

[Code]...

View 3 Replies


Similar Posts:


ActionScript 3.0 :: Sorting An Array With A Custom Function?

Jun 30, 2009

I'm trying to create a custom sort function. This function will sort the pegs in a certain row by their row number (0: lowest -- numRows - 1: highest)For context, here is Adobe's description for the Array sort method: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/Array.html#sort()

My array-building function:

Code:
public function getPegsInRow(row:int):Array
{
var pegRowArray:Array = new Array()
for(var i:int = 0; i < pegArray.length; i++)

[code]....

Unfortunately, the array does not get sorted correctly.

View 3 Replies

Flex :: Extending DataGridColumn For Custom Sorting Function

Aug 25, 2009

I extended the DataGridColumn because I wanted to include a custom itemToLabel function (to be able to show nested data in the DataGrid. See this question.

Anyways, it also needs a custom sorting function. So I have written the sorting function like so:

private function mySortCompareFunction(obj1:Object, obj2:Object):int{
var currentData1:Object = obj1;
var currentData2:Object = obj2;

[Code].....

Whenever I try to sort the column, I get the error "Error: Find criteria must contain at least one sort field value."

When I debug and step through each step, I see that the first few times, the function is being called correctly, but towards the end, this error occurs.

View 4 Replies

Actionscript 3 :: Custom Sorting Algorithms' Speed

Sep 22, 2011

I'm doing a project where I manually create sorting algorithms.After several tests I found out that my heapsort is way quicker than quicksort (I think it should be the other way around), my selection sort is also faster than insertion sort.I'm testing using integers from -100 to 100, randomly generated, 5000 values in an array (I modified this number several times, still the same problems).My quicksort isn't in-place.I thought that maybe flash's recursive functions are slow? my heapsort uses loops, unlike quicksort. That's just a hypothesis though. I start a timer, run the class's exec() function, stop the timer and calculate the elapsed time.[code]

View 3 Replies

Flex :: Custom Sorting Capabilities With Server Side Support?

Feb 22, 2010

The sorting capabilities that are available in Flex assume that you have access to all the data, but I'm using a paginated datagrid (with custom code), the datagrid is binded to an ArrayCollection instance, on the next page call I change the data of the dataprovider and everything works ok, but for sorting I need to override the click or event better override the sort method of the arraycollection

All this is to be able to do a server-side sorting.

View 4 Replies

ActionScript 3.0 :: Custom Sorting Based On Values In Item Render?

Nov 10, 2009

I have a question on coustom sort..I have a datagrid for which one coloum has a itemrenderer. I need to sort a coloum based on the value in the item renderer. In the dataprovider for the datagrid i have a numeric value. Based on the numeric value in dataprovider i have a String associated with that value which is shown in UI. I need to sort based on the statusLabel associated with the numeric value.

[Code]...

View 3 Replies

ActionScript 2.0 :: Call A Custom Function From Another Custom Function's Parameter?

Apr 1, 2008

I want to call a function from another function's parameter but I don't know how and don't know if it is possible.I've considered this as a solution but it didn't worked.

Code:
function myFunc(target_mc:MovieClip, nX:Number, nY:Number, cFunc:Function) {
target_mc._x += nX;
targen_mc._y += nY;
target_mc.onPress = cFunc;

[code]....

View 2 Replies

ActionScript 3.0 :: Sorting Out The Play/pause Function On The Button?

Nov 9, 2011

I have this fla file... 40 frames to be exact, each frame is a movie clip with AS3 code for a fade transition. I implemented to auto play with delay of 10 seconds on each frame, then next frame and so on. I also have implemented the next and prev button (next frame, prev Frame) and the arrow keys on keyboard function.
 
Now I need help on sorting out the play/pause function on the button (play>pause button) I did a code, it pause on the the frame when i click pause, but the as code on the mc clip on the frame proceeds and when i press the play button, it plays at current frame, but plays fast straight to the last frame.

[Code]...

View 7 Replies

Actionscript 3 :: Sorting Function Not Called In Flex Datagrid?

Oct 11, 2009

I am creating a Datagrid in AS3, and adding a sort function to a column. However, this sort function does never get called. Any ideas?

dg_gruppenUebersicht = new NestedDataGrid;
dg_gruppenUebersicht.sortableColumns = true;
dg_gruppenUebersicht.dataProvider = arrCol_gruppenTnAkt;

[code]....

View 1 Replies

ActionScript 3.0 :: Creating Datagrid With Sorting Options & Filter Function

Jul 20, 2011

function createDatagrid():
//datagrid
var dp:DataProvider = new DataProvider();
//addin the entries

[Code]....
 
The above are my doubts for sorting a datagrid and a filter function for datagrid.

View 14 Replies

ActionScript 3.0 :: Sort Function When Sorting The Array Contains Several Elements That Are Equal

Nov 17, 2011

There appears to be a problem with the sort function when sorting the array contains several elements that are equal. I tried to illustrate this in the simplest form below:

[Code]....

View 5 Replies

ActionScript 3.0 :: Depth Sorting Function Starts Messing Up (sortchildren())

Jul 28, 2010

I need the enemies to move around the obstacles on screen. I have tried several methods but it seems to screw up other functions in my game... For example the depth sorting function starts messing up (sortchildren()). I think its because i'm such an amateur.

View 8 Replies

Flex :: Sorting - Best Way To Custom Sort A Flex Array?

May 11, 2011

Here are the strings this array can contain (in the correct order):

'recipients,' 'columnSelector,' 'headerImageLink,' 'title,' 'mainText,' 'text,' 'bodyImage'

Now, to sort them, I obviously don't want to do something like this:

if( a == 'columnSelector' && b == 'headerImageLink' ) return -1;
else if( a == 'columnSelector' && b == 'title' ) return -1;
else if( a == 'columnSelector' && b == 'mainText' ) return -1;

So that brings up an interesting thing. I know you can optimize the above some using something like this:

if( a == 'columnSelector' || a == 'bodyImage' ) return -1;

This would get the last two, but lately I have just wanted community input on issues I have had in the past. So the question is, what is the best way to write a custom sort, using a relatively random order (not alphabetical, etc)?

View 1 Replies

ActionScript 2.0 :: "User Function"-Type Sorting Available?

Aug 11, 2006

as always, I only drop by when *I* have a problem... I'm such a selfish bastard (is it allowed to even say "bastard" on here?) Anyways. I know that (in PHP) there's a way to use user-created functions to sort an Array (usort & uksort) by custom comparisons- you pass the Array and the name of your function and it uses your own function to "re-organize" the array.

Is something like that also available / possible in Actionscript? Or do I have to write my own function where it loops through the array entries and writes them into a new array? I need it relatively quick so setting up my own might take too long. The setup is pretty much this (just in case you're interested):

[Code]...

View 3 Replies

ActionScript 3.0 :: Creating A Custom Function?

Sep 2, 2009

i have a set of "if conditionals" that should always be together,what i want to do is to put these conditionals in a function... then call the function once needed. i want to call this function once the flash starts playing + when i click on any of the 3 buttons.

here is the code so far:

ActionScript Code:
var btn1:Boolean=true;
var btn2:Boolean;
var btn3:Boolean;

[code]....

the problem is button1 should have no eventlistener once the movie starts playing, but it has all listeners... so how can i make AS reads BtnStatus function once it starts loading

View 2 Replies

ActionScript 3.0 :: Custom Events - Any Way To Call Function?

Jul 29, 2009

The fact is that the "dispatchEvent" method must be placed into the code or timeline where the "event" happens, then it can be trigged and the function associated with the event will be invoked. Ok, it is understood. Nevertheless, my question is: what's the point to create an event to trigger the a function call, if I can simply call the function instead directly???

Code:
package{
import flash.events.Event;
public class CustomEvent extends Event{
public static const ONSOMETHING:String = "onSomething";
public function CustomEvent(type:String){
super(type);
[Code] .....

If I can do simply:
Code:
DoIt();
function DoIt(){
trace ("Done!");
}
What I mean is that custom events doesn't look like as REAL events for me, but more like a delegate way to call a function. Differently from Flash native events that are controlled by an internal engine that keep checking if the event happened, in the custom events they must triggered 'manually', and it seems to lose the event main characteristic.

View 6 Replies

ActionScript 3.0 :: Accessing The Function Of A Custom Class?

Dec 26, 2009

I want to be able to make my own math-functions, so that I don't have to write the same trivial functions in all my classes. I would like to import a class called something like MathExtended, and then use functions like this:

MathExtended.sign(x)

I have made an example that tries to import a custom class like that:

Code:
/*
This is the main script which my fla. runs.
*/

[Code].....

View 3 Replies

ActionScript 3.0 :: Function That Creates Custom Displayobjects?

Mar 18, 2011

ActionScript Code:
private function drawMap(tile1:DisplayObject, tile2:DisplayObject):void
{
var _tile1 = tile1;

[Code].....

The idea behind this is to store custom sprites in an array and then feed the array to the drawMap function, which would use the sprites from the array to draw a map.

View 1 Replies

ActionScript 2.0 :: Custom _alpha Function Not Working (one Way)?

Jul 8, 2011

I'm trying to fade a piece of text that I'm loading via XML in and out (as well as moving it's location in and out).* The fade out part is working fine, and as long as I have a _alpha.100 command where I'm currently calling my "slidein" function (really the fade in function) it works fine. No idea why! I've tried about 100 different placements and I'm stumped.. It's very perplexing.*

ActionScript Code:
function loadXML(loaded) {
if (loaded) {

[code].....

View 2 Replies

ActionScript 3.0 :: Custom Easing Function With Bounce

Aug 20, 2009

I've been trying to find an easing generator that supports bounce but have found none. I want to create an easing function that starts as a easeInSine (or quad) and ends as en easeOutBounce (imagine dropping an object on the ground). I've already thought of splitting up the tween in two. Just realised that the easeOutBounce actually starts a little bit like easeInSine but I would like to enhance that part to make a steeper curve.

View 4 Replies

ActionScript 3.0 :: Communication Between Custom Function And OnComplete?

Feb 21, 2012

I created a function with input variables, so I don't have to repeat this function X amount of times. But within the function is a TweenLite call and that call has an onComplete. This onComplete somehow doesn't understand what the variables filled in in my function represent.

PHP Code:

function navMenuInput(check01:Boolean, check02:Boolean, movieClip01:MovieClip, movieClip02:MovieClip){        if(check01 == true && check02 == false){            if(movieClip02.stage){                TweenLite.to(movieClip02, 1, {alpha: 0, onComplete: navMenuInputComplete} );            }else{                navMenu.addChildAt(movieClip01, 0);                movieClip01.x = navMenu.width-

[code]...

EDIT:I think I can make this a bit more clear when I explain what this is supposed to do:This menu can reach it's end via different routes. So the user can choose Path A or B, but what I'm trying to set up here is. If A is on stage, A should be removed first before B is placed and vice versa. And because this happens for about 4-5 times I wanted to shorten the code by using something like this.

View 4 Replies

ActionScript 2.0 :: Custom Function W/ Variables Not Working?

Nov 29, 2004

I'm using Flash MX 2004.

PHP Code:
// function to automate the hit tests
function hitClip (aCPlaceNum, loopNum, loopName, aCButtonNum) {

[code]....

View 2 Replies

Professional :: Custom Event Never Reaching Listening Function?

Jul 7, 2011

I have been having a problem usign a custom event... I attached it to the the main class using "addEventListener" and fire it off with "dispatchEvent" in another class. I checked that it was attached to the main class using "hasEventListener" and it returned true, also "dispatchEvent" returns true... but it ever reaches the function that I attaced it to... is there any thing I am missing?

View 3 Replies

AS3 :: Flash - Smooth Custom Movieclip Repel Function?

Oct 30, 2010

I wrote this repel function (below) for 2 movieclips and I call it from a timer instead of an enter_frame listener (speed), but it has the tendency to jerk and not be very smooth. How can I smooth the movements?

function repel(mover2, mover) {
var xdiff:Number = mover2.x - mover.x;
var ydiff:Number = mover2.y - mover.y;
var dist:Number = Math.sqrt(xdiff*xdiff + ydiff*ydiff);

[code]....

View 1 Replies

ActionScript 3.0 :: Tell Stage To Do GotoAndStop(); Function From A Custom Class?

Oct 11, 2011

I am trying to make a game, I have worked out all the movement, shooting, updating stats techniques, but I have a problem that is not so obvious to me. I need to go to new frame(stages' new frame) every time left mouse button is pressed.

How can I tell stage to do gotoAndStop(); function from a custom class?

View 9 Replies

ActionScript 3.0 :: Create Custom Classes And Function Library?

Mar 5, 2012

let's say I have a function in a package like this:

ActionScript Code:
package{
function traceObject(target:Object){
trace(target);
}
}

Now, I want to use this function in every flash application just like I do with

ActionScript Code:
import flash.display.*

1) How can I do that?

2) Can I have classes and constants in the same package too?

View 9 Replies

Actionscript 2.0 :: Call Function With Different Parameters Via Right-click Custom

Apr 7, 2009

I have this custom right-click menu. I need to call the reactOnClick() function with a specific parameter when clicking a specific right-menu item. I want to avoid multiplying the function for each right-click item.

Code: Select all//set up the custom right-click menu
rcnMenu = new ContextMenu();
//the value below is here just for testing purposes,
//the actual value could be anywhere between 3 and 13
var numberOfItemsTakenFromXml:Number = 5;

[Code].....

View 1 Replies

ActionScript 2.0 :: Call A Dynamic Function From Within A Custom Class

May 28, 2008

i have created a class that so far works great. what i need to do is get that class to accept a function as one of its parameters. so for example:

[Code]...

and when the class is finshed to use the passed function name to call a internal function in the flash movie I don't even know where to begin or what its called to even do a search on it.

View 8 Replies

ActionScript 2.0 :: Passing Parameter To GotoAndPlay In Custom Function

Dec 13, 2004

I have a custom function with parameter. I'm trying to pass the parameter to the gotoAndPlay as follows. This is where the function is called...

Code:
myButton_btn.onPress = function() {
myFunction("Apply");
}
This is the function...
Code:
myFunction = function (fLabel) {
trace(fLabel);
gotoAndPlay(fLabel);
}

Basically "Apply" is a frame label that I'm trying to send the playhead to. The fLabel paramater traces out properly, but the gotoAndPlay doesn't send the playhead to the appropriate frame label. It sends it to 4 frames before the end. It's really weird. Even if I add frames to the timeline, it still sends it to 4 before the end. I can get it to work perfectly in a "new" flash document, but not in my existing document.

View 11 Replies

ActionScript 3.0 :: Call A Function From Custom Class On Button Click?

Oct 9, 2009

Let's say I have a Widget class that extends MovieClip:

[Code]...

How would I call doWidget(i:int) from the specific widgetRay[] instance clicked, using onClick from the main?

View 4 Replies







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