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


Similar Posts:


Actionscript 3 :: Algorithms : Implementing Custom Hash Table Based Dict?

Aug 19, 2011

I am learning programming abstract data types. Trying to build custom hash table based dict.SO far I've created a class place holder.

public class HashMapDict implements IDict
{
private var _map:Array;[code].....

What I am thinking about is to use cryptography libs for hash generation. But I am a bit confused with how it should work. e.g. Tried to look on several libs like as3crypto (http:/url]....) and it seems to produce hash in a way I don't really think can be used for indexes in arrays.

View 3 Replies

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

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

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

Flash :: Custom DEFLATE Implementation To Speed Up PNG Encoding

Jun 13, 2011

I'm optimizing a PNG encoder for use within Flash SWFs (but I'm writing it in HaXe).I've so far managed to speed things up a fair bit, mostly by using speedy memory read/writes.While profiling my code, I noticed that about 75% of the time is spent in a single call to Flash's built-in compress() method, which uses the zlib algorithm (which uses DEFLATE in turn).I'm not too fussy about compression ratio, but faster compression would be awesome. So, I was wondering if it's worthwhile to try to implement zlib/DEFLATE myself. A little searching has turned up the zlibC.implementation source, but it's not exactly light reading (or easy to port!).Are there any simple implementations of zlib/DEFLATE that I could use as a starting point? I'd rather not have to wade through the two specs, especially since I don't know whether an implementation running in AVM2 could even perform as fast as the native Flash one in the first place.

View 3 Replies

Flex :: Algorithms Use For Audio Volume Level?

Jul 22, 2009

Let's say I have a slider that can go between 0 and 1.The SoundTransform.volume also ranges between 0 (silent) and 1 (full volume),but if I use a linear function,let's say SoundTransform. volume = slider.volume, the result is rather not pleasing.I really haven't studied the human ear,but I overheard once that human perception is logarithmic, or something similar. What algorithms should I use for setting the SoundTransform.volume?

View 7 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 3 :: Vector Graphics Flood Fill Algorithms?

May 1, 2011

I am working on a simple drawing application, and i need an algorithm to make flood fills.The user workflow will look like this (similar to Flash CS, just more simpler):the user draws straight lines on the workspace. These are treated as vectors, and can be selected and moved after they are drawn.user selects the fill tool, and clicks on the drawing area. If the area is surrounded by lines in every direction a fill is applied to the area.if the lines are moved after the fill is applied, the area of fill is changed accordingly.Anyone has a nice idea, how to implement such algorithm? The main task is basically to determine the line segments surrounding a point. (and storing this information somehow, incase the lines are moved)[code]

View 3 Replies

Actionscript 3 :: Javascript Implement Math Functions Using Its Own Algorithms Or Outsource To Cpu/processor?

Nov 20, 2011

ActionScript3 states the following:

Note: The Math functions acos, asin, atan, atan2, cos, exp, log, pow, sin, and sqrt may result in slightly different values depending on the algorithms used by the CPU or operating system. Flash runtimes call on the CPU (or operating system if the CPU doesn't support floating point calculations) when performing the calculations for the listed functions, and results have shown slight variations depending upon the CPU or operating system in use.

My web application works with very large and small numbers that I suspect may see a difference depending on which machine is running it (especially with mobile devices whose processors aren't as powerful as desktop machines'). My question is, is this behavior a function of the language?

That is, I assume some languages implement their own algorithms for the above functions, and so may be more consistent (except for differences in round-off errors introduced by the choice of processor/CPU that would exist for all languages).

Anyone know if Javascript has it's own algorithms, or does it outsource them to the CPU/processor like ActionScript?

View 1 Replies

Professional :: Change Speed Of Symbol Without Changing Speed Of Entire Movie?

Aug 7, 2010

I want to add an animated .gif file to my movie.  So I created a new symbol and then imported the .gif file to the stage.  This created the symbol containing the animated .gif.I dragged the symbol onto the scene where I want it.  However, the animation seems to play at a different speed (fps) than normal.  So I changed the fps of the symbol (at bottom of Timeline where it says "fps").  But for some reason this changes the fps of the rest of the entire movie.

View 3 Replies

Flash :: Adjust The Speed Of The Tween To Ensure A Consistant Speed Regardless Of The Value Of StartX?

Dec 13, 2009

I'm tweening a movieclip from startX to finishX. The value of startX varies but finishX is a constant. But as the startX increases in value the animation appears to be quicker. How do I adjust the speed of the tween to ensure a consistant speed regardless of the value of startX?

View 1 Replies

ActionScript 2.0 :: Change A Songs Playback Speed Depending On A Speed Variable?

Jul 24, 2009

is there anyway to change a songs playback speed depending on a speed variable. heres the kicker tho im limited to using only as2.

View 2 Replies

ActionScript 2.0 :: Increasing Enemy Speed /cannot Seem To Change Speed

Mar 23, 2010

I have a movie clip on my scene which has a speed applied to it making it move across the screen. This is duplicated when it reaches the other end of the screen.On my scene I have some action script which is acting as a timer. After a set time I want it to increase the speed of the movie clips, making the game become "harder". I seem to be able to manipulate the alpha of my movie clips but can't seem to trigger the speed increase.If i use a setInterval it seems to trigger the speed increase but it does it each time the movie clip is duplicated (so the delay resets, it does not change once and apply throughout)However, where I am changing the alpha I cannot seem to change the speed.

View 2 Replies

ActionScript 3.0 :: Detecting Mouse Speed And Put Speed Limit?

Sep 20, 2009

How can i detect mouse speed with AS 3.0, and then put speed limit? Also can i use speed var for anything else? *sorry for my bad English, i live in non-english-speaking country*

View 9 Replies

ActionScript 2.0 :: Detect A PC Speed Our Cpu Speed?

Jul 16, 2005

How can I detect a PC speed our cpu speed with actionscript?

View 1 Replies

Actionscript 3 :: Flex 4 Disptaching Custom Event From Custom Component (why Flex Converting Custom Event To Mouseevent)?

Mar 2, 2012

This is NOT duplicate of my earlier post (its is slightly different)But this is similar issue with similar error but its not the same error The error I am getting now is below while dispatching the custom event from my custom component

TypeError: Error #1034: Type Coercion failed: cannot convert events::MapEvent@a74ab51 to flash.events.MouseEvent.
dispatchEvent(new MapEvent(MapEvent.CLICKED_ON_MAP));

Note: The error in my earlier post is giving below error message

Type Coercion failed: cannot convert flash.events::Event@81ecb79 to com.events.ShopEvent

The difference here are two things, the earlier error is while converting flash event to custom event and now this one is while converting custom event to flash event and secondly, I have no clue why it is trying to convert to the mouseevent where I am just dispatching my custom event with proper listeners.

This is my custome event

package events
{
import flash.events.Event;
import ui.map.MapElement;

[code]...

View 1 Replies

Sorting Out Pop-up Windows

Mar 17, 2009

I have been deveolping my new site, which is in it's early stages and have most things working ok but i need to open new windows from buttons in the main swf file. please check out my link to see for yourself! new windows load in the same window ad the main swf. [URL] I have been using this code on the thumbs on my design and illustration sections

on (release) {
getURL("javascript:NewWindow=window.open('url.html ','newWin','width=1133,height=425,left=425,top=113 3,screenX=1133,screenY=425');NewWindow.focus();voi d(0);");
}
each of the thumb windows being a different specified size.

View 1 Replies

ActionScript 2.0 :: Sorting An XML?

Nov 26, 2003

Given an XML file similar to this:

Code:
<class>
<student>

[code].....

View 2 Replies

Flex :: Sorting An ArrayCollection?

Oct 21, 2009

Is there any way in Flex where in we can sort an arraycollection based on strings .I have a dataprovider with strings like "Critical" "High" "Medium" "Low" where in I need to sort it in such a way that I need Critical to be displayed on the top and next High , Medium and Low follows.

View 1 Replies

Flex :: Sorting Dates In Adg

Apr 4, 2011

I have an advancedDataGrid and I would like to sort the adg according one AdvancedDataGridColumn(studyDate) which use strings in format DD/MM /YYYY(I receive like this from the server):But i find another problem, I need to sort the columns of the adg the first time it displays so I used the following function but It doesn't sort from the recent day to old one, I do not know what I can I do cause I set sort.descending= true, any ideas?[code]

View 1 Replies

Flex :: Sorting - Get Value In ComboBox

Sep 26, 2011

I have a one comboBox that I fill as:
for (var key:String in values) {
conns.addItem(key);
}

After that I sorted my ComboBox as:
private function sortConnection():void {
var dataSortField:SortField = new SortField();
dataSortField.name = "data";
dataSortField.numeric = true;
var numericDataSort:Sort = new Sort();
numericDataSort.fields = [dataSortField];
conns.sort = numericDataSort;
conns.refresh();
}

And on finish I want to select item on my specific value in ComboBox. How can I do that? I try:
for (var ii:Number=0; ii<combo.rowCount; ii++) {
var item:String = combo.getChildAt(ii);
if (item == name) {
index = ii;
}}
But does not work. I do not know where I made mistake, and how I can select on specific item in my combobox.

View 2 Replies

Flash :: Sorting XMLListCollection?

Mar 28, 2012

I have been trying to sort an XMLListCollection following instructions like this for some time, without success. Here's the relevant code:

<fx:Declarations>
<s:HTTPService id="photoServ" url="pics.xml" resultFormat="e4x"/>
<s:XMLListCollection id="photoList" source = "{photoServ.lastResult.photo}"/>

[code]......

View 2 Replies

ActionScript 2.0 :: Sorting Xml Categories?

Mar 7, 2007

i'm trying to sort out some xml entries based on an attribute when you click a button. an example of my xml is below.

Code:
<list>
<entries cat="all">

[code].....

View 14 Replies

ActionScript 2.0 :: Get The Z Sorting To Work?

Jul 2, 2003

i just started with isometrics. i got the 3d to 2d coordinates working but i cant seem to get the z sorting to work.

View 2 Replies

ActionScript 2.0 :: Cant Seem To Get Z Sorting To Work

Aug 7, 2009

i just started with isometrics. i got the 3d to 2d coordinates working but i cant seem to get the z sorting to work. please check the fla if you have knowledge in the subject.

View 6 Replies

IDE :: Sorting Again Array Of Objects?

Sep 18, 2009

Trying to re-sort an array of objects from:
var arr:Array = new Array({num:0},{num:1},{num:2},{num:3})
to
var arr:Array = ({num:0},{num:3},{num:1},{num:2})

View 2 Replies

ActionScript 3.0 :: Sorting An Array Of MC's By X/y?

Mar 23, 2010

- Put a bunch of MC's on the stage distributed horizontally.

- Store them in an array.

- yourArray.sortOn("x", Array.DESCENDING)

- loop though the now "sorted" array and trace their x property.

Doesn't work, does it? If it did, shuffle them up and try again (sometimes, perhaps randomly they will be in order).

View 7 Replies







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