Actionscript 3 :: Fastest Method To Find A Complex Type In A List

Apr 12, 2011

I need to know the best method to find an item inside a list (Vector, Array, Dictionary, whatever is faster) of complex type (extensions of Objects and Sprites). I've used "Needle in Haystack" method, but it seems that it isn't fast enough.

E.g. Suppose that I have a collection of Sprites (a pool, in fact). Each sprite will be added to the stage and perform some action. After that, it will die. I don't want to pay the cost to dispose it (garbage collect) and create another (new) one every time so I'll keep the dead sprites in a collection.

Sometimes times I'll call a method that will add a sprite to the stage. This sprite can be a old one, if it is already dead, or a new one, if the pool don't have any free sprite.

One of the scenarios that pushed me to this question was a Particle System. A "head" particle leaving a "trail" of particles every frame and exploding into a flashy multitude of particles... Every frame...

Some times this counts up to 50.000 PNGs with motion, rotation, alpha, event dispatching, scale, etc... But, this is JUST ONE scenario...

At the moment I'm trying to use a Object Pool with a Linked List... Hopes that it will be faster that running a whole Array/Vector or create new instances every frame an let them dye with Garbage Collection.

View 6 Replies


Similar Posts:


Actionscript 3 :: Find A Complex Type In A List (Vector, Array, Dictionary, Whatever Is Faster)?

Aug 29, 2009

I need to know the best method to find an item inside a list (Vector, Array, Dictionary, whatever is faster) of complex type (extensions of Objects and Sprites).I've used "Needle in Haystack" method, but it seems that it isn't fast enough.

E.g.Suppose that I have a collection of Sprites (a pool, in fact).Each sprite will be added to the stage and perform some action. After that, it will die.I don't want to pay the cost to dispose it (garbage collect) and create another (new) one every time so I'll keep the dead sprites in a collection.

Sometimes times I'll call a method that will add a sprite to the stage.This sprite can be a old one, if it is already dead, or a new one, if the pool don't have any free sprite.

One of the scenarios that pushed me to this question was a Particle System.A "head" particle leaving a "trail" of particles every frame and exploding into a flashy multitude of particles... Every frame...Some times this counts up to 50.000 PNGs with motion, rotation, alpha, event dispatching, scale, etc...But, this is JUST ONE scenario...At the moment I'm trying to use a Object Pool with a Linked List...Hopes that it will be faster that running a whole Array/Vector or create new instances every frame an let them dye with Garbage Collection.

View 1 Replies

Performance :: Find Distance Between 2 Points In Fastest Way

Sep 22, 2011

This code calculates the distance between 2 points by using distance formula, Math.sqrt ( (x1 - x2)^2 + (y1 - y2) ^2). My first point has mmx and mmy coordination and second one has ox and oy coordination. My question is simple, is there any FASTER way for calculate this?

[Code]...

View 3 Replies

As3 :: Flash - Fastest Method To Search Next Higher/lower Value In Unsorted Array?

Mar 15, 2011

how to deal with unsorted arrays to get the next higher or next smaller value?

var _myArray:Array = (1,pizza,2,6,8,test,11,16,17,cola)
_myArray.splice(4,1) // > remove number 8 !
trace(_myArray) // > array contains now: (1,pizza,2,6,test,11,16,17,cola)

how can i get the next higher value (= 11) ?

View 2 Replies

ActionScript 3.0 :: Fastest Method Of Determining If A Triangle Is Encompassed By Smaller Grid Squares?

Jul 19, 2010

I've got my 3D sphere to triangle collision detection working now, but I need an efficient method of adding the triangles to the broadphase grid.

This is easy enough if the triangles are smaller than the grid nodes, however - especially given the polycounts I'm working with - it's going to be fairly frequent that a triangle is significantly larger than the grid nodes.

Here's an example.See the yellow polygon? Just adding it the grid nodes by it's vertices results in it NOT being added to 4 grid nodes that it does reside in.

My first thought is repeatedly casting rays along one of the edges from the normal of the edge until you find the intersection point with one of the other edges, of course checking for intersections with the grid edges until you reach the destination intersection with one of the other edges of the triangle. This would work, but is not particularly fast.

Although these triangles aren't being added/removed in real time, only when building the level, when constructing a level with say 100,000 polygons total, I obviously want it to be processed as quickly as possible.

View 14 Replies

ActionScript 3 :: How To Relay Complex Type Via NetConnection To FMS

Feb 22, 2011

I need to send complex type object (marked RemoteClass in Flex) via NetConnection to other clients.

[RemoteClass]
public class ComplexType {
public var _someString:String;
public var _someInt:int;
}

... and using ...
_nc = new NetConnection();
_nc.connect("rtmp://localhost/echo/");
_nc.addEventListener(NetStatusEvent.NET_STATUS, _onNetStatus);
_nc.client = {};
_nc.client.echoCallback = _echoCallback;
[Code] .....

Is there a way to relay strongly typed object via NetConnection? Added callback function source code with ObjectUtil.toString() output

View 2 Replies

Actionscript 3 :: Pass Complex Type Parameters From Flash To A Web Service?

Jul 20, 2010

i've the following snip of code in AS3:

var myWebService = new WebService();
myWebService.addEventListener("load", loadDone);
myWebService.loadWSDL("wsdl_address");
var myOperation:Operation;
function loadDone(evt:LoadEvent)

[Code]....

View 1 Replies

ActionScript 3.0 :: How To Find Out The Type Of A Child

Jul 30, 2009

I want to stop() all MovieClips that are the child of a certain parent.

Code:
for ( var i:Number = 0; i < actor.graphic.numChildren; i++ ){
actor.graphic.getChildAt( i ).stop();

[code]....

View 1 Replies

Flash :: Find Out When A Property Of A Built In Type Changes To A Certain Value?

Jan 26, 2010

I'm having an issue with Movieclips inside my Swf resizing to the wrong dimensions. I'm currently tracing the width of the offending clip every half second, and I can see the value change to an incorrect size at some interval in the logged output. I really want to see what code is changing the width. My plan was to extend Movieclip, override the set width property, and dump a stack trace when the value set is too low. This isn't so simple however. Flash is complaining about undefined reference to UI components that are on the Movieclip fla. Is there a simple way to find out when/why this value changes? I cannot use a debugger.

edit: The reason I cannot just extend MovieClip is because I am getting my Movieclip object from Event.currentTarget.content after using a Loader. I cannot point my Test (extends MovieClip) object at this return value because it is illegal to do so.I have an app with lots of different windows. They all open to a size of around 750x570. One of these windows contains a FusionChart. when I load this, according to my trace, the background Swf I am using changes to a dimension of about 2712x1930. This doesn't make sense to me because it looks the same size as before and at those dimensions it wouldn't even come close to fitting on my screen.If I then close the window and open another, the new window is tiny, but says it has the same dimensions as the original windows (750x570).

It is almost as if the window is scaling to the huge 2712x1930 without showing a change in size, and then showing the next window (750x570) as a size relative to what the huge window would look like. If that makes sense...

View 3 Replies

ActionScript 3 :: How To Find All Objects Of Same Type On Stage

Mar 17, 2011

I'm trying to iterate through all the objects in the stage and I'm not sure how to do it. It's kind of improvised through my previous experience with C# and javascript. First I need the correct list/array with all the stages children. I need to check their type. I have a special custom class which extends Sprite with some additional properties only.

Someone proficient in actionscript 3.0 who can show the proper way to do?
for(var obj:DisplayObject in DisplayObjectContainer) {
if(typeof obj == "Pic") {

View 2 Replies

Wcf :: Flex - Unable To Find Definition For Type From WCF Service

Nov 9, 2011

I have a WCF Service running SOAP and allowing Flex / Flash to connect to it using basicHttpBinding by using the 'Data' 'Import Web Service' option. Unfortunately when I consume and invoke this service within Flex it throws the following error...

Error: Cannot find definition for type
'http://schemas.datacontract.org/2004/07/System.Drawing::Size' at
mx.rpc.xml::XMLDecoder/decodeType()

...when using the following code...

// This will return an array of presentations
var service:PresentationAuthoring = new PresentationAuthoring();
var token:AsyncToken = service.getAllPresentationByClientId(

[code]. ..

This method returns an array of Presentation objects that are retreived by the service. At the moment there are no DataContracts and I'm allowing the POCO Presentation object to be serialised and punted out by the service that works fine. However, this class has a readonly property of the type System.Drawing.Size that derived from appropriate height and width properties. Looking through the generated code, it doesn't register a 'Size' class in the base import schema although it still seems to create a Size class.

An alternative has been to stop the derived property from being serialised using the [XmlIgnore] but that has not worked. I need a way of allowing my Flex application to communicate with my WCF service but it seems to choke on the System.Drawing.Size type and while I could change this, there are other framework types such as Point, Rectangle, etc, etc. that are utilised within the project.

View 1 Replies

ActionScript 2.0 :: Find A Method For Rounding Numbers?

Feb 16, 2009

I cannot seem to find a method for rounding my numbers in the following way:

53=50
55=60
58=60

View 9 Replies

ActionScript 3.0 :: Faster Method To Find An Index Than IndexOf()?

Mar 16, 2011

I have a function that finds the smallest five numbers out of an array of values and returns their index numbers. Here's a block of code from that function[code]...

The whole thing is slow, but I imagine that indexOf() is probably the worst offender. Is there any more efficient way to correlate a series of minimum values with their indexes without having to use indexOf()?

The values don't necessarily have to be stored in _elements, but they're pulled from a multidimensional array so I figure that it's the most efficient I can get at the moment.

View 3 Replies

ActionScript 2.0 :: Unable To Find HMAC Encryption Method?

Jul 20, 2009

i'm need HMAC-SHA1 for doing some encryption, but so far i'm able to found SHA1 in meychi crypto library, but until now i'm still not able to found HMAC encryption method so far.i'm trying to refer to hurlant crypto library, but it's quite confuse as it's using ByteArray which only available on AS3.

View 1 Replies

Flex :: Find The List Item Currently Under The Mouse Pointer?

Feb 3, 2010

I have some List and TileList controls. How can I get a reference to the list item that's currently under the mouse pointer?

View 3 Replies

Flash :: Where To Find A List Of Styles For SetStyle(style - Value)

Jun 23, 2010

Some Flash components have the method setStyle(style:String, value:Object). I wonder where/if I can find a list of the styles that are possible to use here? I want to change the background alpha of a TextInput-component, but can't find the style-name for it.

View 1 Replies

ActionScript 2.0 :: Find A List Of Clips Exported In Frame 1

Nov 5, 2009

So I wondered if there is some way to retrieve a list of all movieclips that are in the library that have been exported in frame 1.

View 0 Replies

ActionScript 3.0 :: Find A Branch And Walk Through A List Of Its Children?

Nov 6, 2010

xml stuff in action script is so... non-intuitive.. cubersome I can compare it to the xml libs that I used in playground sdk, popcap and other .. tinyxml.. ....

I' m trying to make that simpliest thing for about 2-3 hours.. + reading books.. and still can't do it..

what I want to do is:
<xml>
<Weapons>
<Weapon id="canon" rechargeTime="200" impulse="30">

[Code].....

how do I read the all "Weapon" objects listed inside Weapons.. NOTE: I dont want to use the method.. that returns "Weapon" from all over the xml... cause I probably want to list weapons in other sections for other purposes

View 2 Replies

Actionscript 3 :: Return Different Type From Overridden Method?

Jan 13, 2010

I'm extending the AS3 class Rectangle with a class called Bin. I want to override the Rectangle clone() method with a method that returns a Bin object, not a Rectangle object. If I try to override the clone method but specify Bin as the return type, I get a #1023: Incompatible override error. Here's my Bin class:

package {
import flash.geom.Rectangle;
public class Bin extends Rectangle {

[Code].....

This class works, but when I use the clone() method to create a new Bin instance, I get type errors when I try to use the Bin methods on the new instance.

How do I override clone() and send an actual Bin instance?

View 1 Replies

Actionscript 3 :: Define The Return Type For Such Method?

Mar 27, 2011

public function t()
{
if(xxx)return xxx;
//don't return anything
}

How to define the return type for such method?

View 5 Replies

ActionScript 3.0 :: FileReference Type Method ... Weak

Dec 18, 2009

So there I was, creating a small app that allowed user to upload custom images. Everything went smooth, until......<insert horror music here> So you want to validate that its an image, and not something else. Well you restrict it with the File filter...but there are ways around that. So as a double check, you check the file type after a file is selected. <drum roll>

Awesome, the type method returns null if the image doesnt have the proper headers....what the hell....So most images are compressed for smaller file size, thus the headers are stripped out. So...Type method appears to be useless....There was a simple way around this using the name method..but what the hell...type method is weak!!

View 4 Replies

ActionScript 3.0 :: Constructor Method Return Type?

Jun 6, 2010

Some constructor methods I've seen have the return type :void, even though they can't actually return any values anyway. If it's not required, is there a standard/best practice for that?

View 4 Replies

Actionscript 3 :: Undefined Method Through A Reference With A Static Type

Mar 10, 2012

I have been away from actionscript for a long time and not 100% why this is happening, I will simplify the class below[code]...

call to a possibly undefined method through a refernce with a static type?

View 1 Replies

Professional :: Find A Method Of Increasing The Resolution Of An Executable That Runs Off Flash?

Feb 28, 2012

I've been trying to find a method of increasing the resolution of an executable that runs off flash. To be specific the program is a game called 'Realm of the mad god' originally a browser game but is now also a free to play steam title, Having browsed through the config files I couldnt find anything talking about resolution and I was wondering if there are any advanced flash features that allow the user to force the application to run a specific resolution.
 
PS: I don't have the highest hopes but I thought if anybody knew it would be someone from the flash community.

View 1 Replies

ActionScript 2.0 :: Find A Simple IP Detect Method In Flash Working With A MySQL DB Via PHP?

Oct 27, 2006

I wish to detect and store the IPs of the users of my site which is All-Flash-Built. My goal is to later have the ability of banning some users...Where can I find a simple IP detect method in Flash working with a MySQL DB via PHP?

View 1 Replies

Obtain Method List For A Given Class Name?

Dec 31, 2010

I want to obtain a list of methods available to a class, given its name. How can I do this?

View 1 Replies

Flex :: Find Out Deselected Item In Spark List With Multiple Selection

Aug 3, 2010

In a spark list I could use the change event to find out which item has been selected or deselected. The dispatched IndexChangeEvent object has the properties newIndex and oldIndex holding this information.

But with multiple selection allowed this doesn't work anymore because newIndex and oldIndex could refer to indices of still selected elements.

A solution would be to copy the selectedIndices vector to another variable and compare this variable with selectedIndices after a change in selection, but this seems to be somewhat complex.

Does anyone know if there is an easy way two get the index/item a user is deselecting while other elements are still selected?

View 2 Replies

Flash :: Find The Size Of The Area In A Bitmap Which Has Been Filled Using The Bitmapdata.floodfill Method?

Sep 27, 2011

I am using the floodfill method to colour-in sections of a bitmap image. That part is easy enough but the issue comes in with the way I am adding an effect to the colour fill routine.

To add the effect, first a copy of the bitmap data is created and floodfill is used on that instead of the original bitmap. Then the bitmapdata.compare method is used to set the alpha value of everything apart from the filled-in section to 0 and the result is saved in another bitmapdata. After that, a 1 px radius circle sprite is added to the stage and is being tweened to the image dimensions and its mask is set to the sprite which contains the result of the compare operation.

This works perfectly except for the fact that the fill sprite has to be tweened to the complete image dimensions irrespective of how small the area is being coloured-in since I am not able to find a way to get the dimensions of the fill area. I am doing an bitmap image update at the end of the tween and I have to disable user interaction till the tween is complete to avoid the errors which come in if another fill-in operation is started before the base image has been updated. If I could somehow get the dimensions of the fill area then the time during which I have to disable the user interaction will go down considerably.

View 3 Replies

Flex :: Handling Mouse Click 4 List To Find The Selected Item (since ItemClick Is Gone)?

Dec 8, 2011

I have prepared a simplified test case for my question. It will run instantly in your Flash Builder if you put the 2 files below into a project.I'm trying to display a List of strings and a confirmation checkbox in a popup:In the real application I dispatch a custom event with the string selected in the list, but in the test code below I just call trace(str);My problem: if I use click event, then the window closes, even if I click at a scrollbar (the !str check below doesn'twhen an item had been selected in previous use). And if I use change event, then the window doesn't close, when I click on the same item as the last time.riting a custom item renderer and having a click event handler for each item seems to be overkill for this case, because I have strings in the list.Test.mxml: (please click myBtn few times - to see my problems with click and change)

<?xml version="1.0" encoding="utf-8"?>
<s:Application
xmlns:fx="http://ns.adobe.com/mxml/2009"

[code]........

View 3 Replies

ActionScript 2.0 :: Type A Word In A Textfield And Have It Search For A Match Through A List Of Words In Xml

Jun 1, 2007

I'm trying to figure out how to get this started. I'd like to type a word in a textfield and have it search for a match through a list of words in xml. There would be 26 xml files containing a list of words starting with a letter of the alphabet.

View 2 Replies







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