ActionScript 3.0 :: Sort Objects Depths Based On Their Y Position
Jun 12, 2008
I've been trying to sort objects depths based on their Y position but have not been able to do it efficiently. I was able to successfully sort objects with a selection sort algorithm and a quick sort algorithm; however, both have only been partly successful. Selection sort gets about 8-10/30 FPS with 13 objects and gets about 14-18/30 FPS. This is not good enough as I figure I could have as many as a hundred objects to be sorted at once.
After digging around, I found that array.sort() is more efficient than a quick sort implemented in AS3 and that calling swapChildren() or swapChildrenAt() at every swap was bogging it down. So now I am copying the objects array and sorting it with sort() and then comparing the two and swapping displayObjects so as only to call the swapChildren() or swapChildrenAt() method once per element. It appears to be running, and at full speed, though it won't swap correctly. Here is my code:
[Code]...
View 14 Replies
Similar Posts:
Oct 23, 2010
In my code I am creating MCs and having them drop down the screen at varying speeds, but am having a hard time thinking of an easy way so that if one MC 'overtakes' another slower-moving one it will be displayed above it.I really don't want to have to run a hit test every frame for every MC through the array of MCs..
View 3 Replies
Apr 17, 2011
Any smart people out there who can tell me why this function Im working on to automatically sort the depths of objects placed on the 3D plane is only working intermittently? It seems to work every second or third iteration?[code]Is getChildAt(i) reliable? IE does it return the same order each time it runs or is it based on depth? looking at the manual suggests that it's probably the latter so I guess I'll need to make my own array ordered by the time the sprites were added to the parent and work from there. Is there a better way?
View 1 Replies
Mar 23, 2011
in a pseudo-3D chess game a user can move pieces on the screen which also involves resizing them according to the law of perspective.
The pieces positions are stored in a SharedObject so that next time the SWF is started the pieces get to the position they were left. Problem is that I also need to store each piece's depth which is being changed during the game. To store the depths is trivial. How then to assign the depth to each object? Depth is a read-only property, is it not?
I can iterate through the all pieces comparing their scale and swapping the depths is they do not correspond to the size of the piece, but this seems to be a bulky code.
View 0 Replies
Mar 12, 2011
I have an array of n Movieclips placed in a circle rotating around the y axis. I have to make sure that the MCs with the higher z values are behind the ones with a lower value, i.e childIndex. I tried a couple of approaches but I don't seem to get it right.
View 2 Replies
Jan 11, 2010
Does anyone know how to sort an array based on the length of the instance name?
I have an array full of instance names and they are different lengths. I need them to sort based on the number of chars.
View 1 Replies
Aug 23, 2004
how to sort a sub array based on one element within it? I have an array which contains a number of sub arrays. The sub arrays each have an element consisting of a single number. I need to sort the sub arrays within the "mother" array using this number as the key.
View 4 Replies
Feb 10, 2010
Updated question: Is there a way to sort dynamic texts based on the variable (or simple value) they represent? Old dribble: I'm looking for some pointers for a problem with making a table. It may be that I have started off in the wrong direction - anyways, I'm stuck now. The .png displays my objects, and how they are connected/grouped. The highlighted (red) shows the variable containing the points.
The pink with the most points should be displayed higher than the rest, and 2nd most points should ofc be 2nd highest. I have tried taking the red variable out of the pink, but I could not think of a way of moving the red variable based on its own value. I'm going to edit the red variables (as the world cup goes on), and there is no need for cookies and such. And if there is a simpler way of doing the setup, let me know. I'm using SwishMax3 (SM2 up till a few days ago, so I'm more used to as2..)
View 5 Replies
Apr 9, 2010
Currently when sorting in a flex grid, the sort arrow that shows whether the column is sorted ascending or descending is right aligned to the column. Is there anyway to change the position of the sort arrow, such as applying padding?
View 1 Replies
Oct 2, 2010
I have created an object and I need to sort its elements. Is this possible?[code]...
I was able to do what I wanted by turning my object into an array and then sort, but my arrays gets pretty large and is regenerated often.
View 1 Replies
Mar 14, 2006
Make an array with some objects, let's say something like this[code]...
View 2 Replies
Apr 8, 2009
using this code...
Code:
var carsArray:Array = new Array();
carsArray.push({car:"mazda", year:1982, options:{price:15000, rating:"C"}});
carsArray.push({car:"ford", year:2001, options:{price:25000, rating:"A"}});
carsArray.push({car:"volkswagen", year:2001, options:{price:13000, rating:"A"}});
carsArray.push({car:"volkswagen", year:1997, options:{price:14000, rating:"F"}});
carsArray.push({car:"volkswagen", year:1997, options:{price:15000, rating:"A"}});
carsArray.push({car:"volkswagen", year:1997, options:{price:18000, rating:"B"}});
[Code]...
View 2 Replies
Sep 19, 2004
I want to sort an array that contains object references. I want to sort on one of the values held by the objects.
I have the following sample code, say:
Code:
ActionScript:abc = new Array();
abc[0] = new Object();
abc[0].anotherObj = new Object();
[Code].....
View 2 Replies
Feb 22, 2009
The code doesn't work.
The getChildIndex and setChildIndex methods give error because cont[i] is not child of my object.
which is the fastest way to reorder depth of the objects ?
Code:
container.rotationY= container.rotationY + (mouseX-width/2)/100;
for (var i:uint=0; i<container.numChildren; i++) {
cont[i]=container.getChildAt(i);
[Code].....
View 5 Replies
Sep 14, 2010
I'm trying to sort MCs on stage that belong to different instances of different objects.
[Code]...
is there a simple way to use the Depth Management methods to control their sorting order? Right now, all I know how to do is place objectTypeB either in front of or behind all members of objectTypeA.
View 3 Replies
Sep 8, 2006
I am trying to sort XML data based on an attribute "price" (or p). I'm trying to sort the prices numerically so that, for example, 1230.00 does not show up before 19.00. I have defined a preliminary price sort function as follows:
[Code]...
How do I edit this function so that the prices will display in numerical order rather than string value order?
View 4 Replies
Mar 25, 2005
I need help with page "Thumbs" (as first frame), page "List" (as second frame) and Image gallery (as third and base). So, every frame have one own XML file...When you choose some thumb or list line, you must came to this image in the gallery. Easy, sure.. but i don't know what Function exactly i need to use.It's one flash move, hence it doesn't work with getURL or loadMovie...Some exemple with 3 separate pages here: yuri.fr
View 1 Replies
Jul 20, 2011
So I'm working on my portfolio and I got this problem. The code posted scrolls the sprite "cellContainer" based on the position of stage.mouseY. Perfect.Problem is that I want stage.mouseY to equal the entire cellContainer height. Kind of like how a small tablet equals a huge monitor. So when stage.mouseY = 0,cellContainer.y = 0 and when stage.mouseY = stage.stageHeight, cellContainer.y = stage.stageHeight - cellContainer.height. Right now, it scrolls, but it takes a while to scroll throught the entire height of cellContainer. I want it to be proportional to stage.mouseY.
Actionscript Code:
private function scrollStart(e:Event)[code]....
View 4 Replies
Jan 14, 2010
I am working on a site, that has 5 main pages: the home, and four sub-pages. Essentially, I have an element that slides up over the screen anytime you click "from" the home page to one of the remaining pages. Consequently, when returning to the home page, the element slides away / off the screen.
I am thinking the best way to handle this is with a conditional statement, but not really sure at all how that code would look especially in relation to position. My thinking for the code would be as follows:
[Code]...
View 1 Replies
Jan 3, 2011
I would like to input a certain (x,y) coordinate and have a function return which movie clip is based at that location. Is such a method possible, to refer to a movie clip based on its position rather than instance name?
View 1 Replies
Feb 24, 2012
how to get the X and Y coordinates of a character in a string based on index? I find it odd that I can get the exact letter and index by clicking a character in a text field, but I haven't found anything in code that can get those coordinates without a user click. Seems like they would have to know the x,y of the individual indexs to be able to tell you what letter you're clicking based on your own mouse coordinates.
View 3 Replies
Oct 10, 2010
I'm doing an online advertising format (728x90 leaderboard). I have embedded a video into the flash file which covers 1/3 of the format (242x90).What i need to do is seek this video from 0% to 100% based on the mouse position over this area (242x90). I'm guessing it would be easier if i created a button over the video which is 242x90 but i would still be looking for the code that seeks the video based on the mouse position over the button.
View 7 Replies
Jun 18, 2005
check out: [URL] - great site
Does anyone know how this scrolling based on mouse position works?
View 8 Replies
Nov 27, 2010
I have an array that is structured like so.
[Code]....
Normally, I'd just like to sort the array alphabetically using the name field, which is easy enough using the following code. However, I'd like to create a radio button called 'loadedRadioButton' and when it's click on, I'd like to sort the array on the loaded value first(any items with loaded=true should be at the top, sorted alphabetically), then afterwards, any other items with loaded=false, sorted alphabetically should follow afterwards, how can I do it?
View 0 Replies
Mar 5, 2010
Here is a website that needs a sort function to sort the video by Last name. [URL] I would like to have a link that popped up videos sorted by last name. Please take a look at the following site for an example. [URL] When you click on seconds in the menu below, it opens a pop-up window that sort the videos in a certain way. If you are willing to,I will give you the source file of what it currently has on [URL]
View 1 Replies
Jan 10, 2009
I have created a document 600x300 filled with buttons for a rollover effect. I want to be able to play sounds dependant on the x and y position of the mouse without having to use objects that interfere with the buttons.
View 2 Replies
May 25, 2009
I'm trying to make a faux 3D rotation animation where if the user mouses to the right the object rotates right and if the user mouses to the left the object rotates left. Depending on how far they move the mouse the rotation should speed up or slow down.I spent a lot of time making an object in 3d studio max and importing the animation of rotation as JPEGs onto the timeline. I figured the most efficient way to go about this would be to make the mouse control the timeline instead of the object itself.
View 4 Replies
Oct 2, 2009
I have a thumbs_mc with thumbnail images. Within thumbs_mc, I have a transparent overlay_mc that functions as a button. Mouse over the overlay_mc and the alpha chages so there is a tint over that particular thumbnailWhen overlay_mc is clicked, the main timeline goes to a particular frame label.What I need to do is have the position of the playhead on the main timeline also determine the alpha of the overlay_mc so the viewer knows which thumbnail is playing.
View 1 Replies
Mar 26, 2009
I am attempting to create 360 degree spin-around product viewer. So far I have a movie clip with 24 frames, each one with a different 15 degree angle shot of the product. Upon playback of the movie, the product appears 3D, spinning 360 degrees.
That was the easy part. Now what I need is to be able to click and drag the product to change which view you are seeing (or which frame in the mc you are on) thus producing a spinning effect. How can you code, in AS3.0, that when the mouse is clicked and drug, go to a certain frame based on the current X position of the mouse?
View 21 Replies
Mar 19, 2012
Is there a way to get the broad position of a user based on the IP address? (I'm building an Adobe Air desktop app for notebook users)
View 1 Replies