ActionScript 3.0 :: Outweigh The Pros And Cons Of Using Vector Vs Array
Jan 22, 2010
I'm developing a small library and trying to outweigh the pros and cons of using Vector vs. Array. So far, I can only think of a few things to think of: Vector only works for FP10, while Array works for both 9 and 10. Vector is typed (which is a wonderful, fabulous thing), but if I'm only using the Array as a private variable, so I have full control over what goes in and comes out of it, this factor may not play as great a part anymore, but definitely great protection.
I believe I heard somewhere that Vector is a lot faster than Array, yet in a quick inconclusive speed test I did a while back, it didn't seem to make any real difference at all. Is Vector really faster than Array? If so, is it faster in all aspects, or only faster in certain situations just as uint is only faster than Number when using byteshifting?
I was using the serializing approach between Flash and PHP for the longest time before AMFPHP had its 1.0 release (wow...that was a long time ago...in 2006)!Serializing using a sepiroth's AS library paired with PHP's built in serializing functions worked and I didn't change it because it did the job.
Should I switch over to the AMF format and technology? One pro is that the data exchange is probably more efficient for AMF because it's a binary format.I've also see other scripting languages/frameworks such as Python/Django, Ruby/Rails supporting AMF. I guess AMF is also a standard format. Does each language serialize data differently?
I'm thinking about using Haxe in place of AS3.What are the disadventages of that?Difficulties with using native AS3 ibraries.Difficulity of debugging after language translation.Haxe is quite young, it may have some rough edges. Does it?What are the adventages? I've heard:
Performance.Multiple targets (But I don't see how that is useful)Better typing that AS3 Maybe better syntax.Haxe is big enough that there should be more. What are the pros of Haxe?
Edit:If there are no real disadvantages then why Haxe is not replacing AS3?
1067: Implicit coercion of a value of type __AS3__.vec:Vector.<Foo> to an unrelated type Array.Really? Doesn't Vector include all the properties, methods and signatures of Array? Is there some low level reason Vector cannot be cast to Array?
I've been working on an xml gallery. The website scales according to the browser window. Some of my work is fine lineart and any scaling seems to cause a lot of aliasing. If I publish it with Flash Player 7 the scaling is fine.This may sound like a naive question but what are the cons with publishing a portfolio with an older Flash Player?
I've run into a strange Vector out of range error when trying to splice a Vector array. The idea is to cut off the Vector array after a certain point....
var vec:Vector.<int> = new Vector.<int>(); vec.push(1);vec.push(2);vec.push(3);vec.push(4);vec.push(5); vec.splice(3,vec.length); // output RangeError: Error #1125: The index 5 is out of range 5.
The strange thing is that it works perfectly, if I change the Vector to a regular array like:
I have a quick question for you all. I'm trying to convert over some ActionScript code to C++ and am having a difficult time with this one line:
private var edges:Vector.<Array> What is this exactly? Is this essentially a multidimensional vector then? Or is this simply declaring the vector as a container? I understand from researching that vectors, like C++ vectors, have to be declared with a type. However, in C++ I can't just put down Array, I have to use another vector (probably) so it looks like:
I don't expect you guys to know the C++ equivalent because I'm primarily posting this with AS tags, but if you could confirm my understand of the AS half, that would be great. I did some googling but didn't find any cases where someone used Array as it's type.
I've run into a strange Vector out of range error when trying to splice a Vector array. The idea is to cut off the Vector array after a certain point...
ActionScript Code: var vec:Vector.<int> = new Vector.<int>(); vec.push(1);
I've been working on this for a while, and thought I understood the BitmapData class at least well enough to do basic stuff with it, but I'm doing something wrong.
I'm trying to make a preload function that will load external JPEGs, store them in an Array as BitmapData objects, then distribute them to thumbnail objects after all the images are loaded. The thumbnails are based on an external class I wrote, which already has a function to accept variable data.
My problem is, I can't seem to find a way to store BitmapData objects in an Array. I've even tried using a Vector.<BitmapData> object, but I get the same result, which is no data stored.
Here's the function, isolated from the rest of the script.
[Code]....
The result of this function is supposed to be, a series of images loaded one after the other, stacked 5 pixels down from each other. However, the actual result is, only the last loaded image is displayed. That's true for any number I place in the 'for' loop, only the last loaded image gets displayed.
Obviously I'm doing something wrong with the loading of the 'bitBucket' BitmapData, because it seems to be writing over the previous BitmapData in the Vector series.
Below is a method to populate a vector with a list of strings
PHP Code:[code]....
However, I have an existing array that contains a list of strings.How would I transfer those contents within the array into the vector?The basic way I can think of is using a for loop, and push the values in.
How do I initialize a vector with an array of values? I tried this and it complies fine, but does not work!
Code: langs = new Vector.<String>(["en","fr"]);I also need to load an arbitrary array into a vector, like this: Code: langlist = ["en","fr"]; langs = new Vector.<String>(langlist);
I need to copy a 2 dimensional Array or Vector (8x8), the only success i have had so far is using 2x For loops actually assigning the primatives from one Array/Vector to another (works for 1 or 2, but on the scale i need to run this it is unsuitable).
After a bit of digging on the internet i saw that .concat() is the fastest and most code-efficient way to copy, but i can't seem to get it to work?
Here's what i'm doing:
Code: var _squares:Array = new Array(); for (var i=0; i<8; i++) {
How would you go about initializing a Vector. with say the values 1, 2, 3, 4, and 5.
Logic would say you could do newVector = new Vector. ( [1, 2, 3, 4, 5] );
You could also try something like this...
var tmp = [1, 2, 3, 4, 5]; newVector = new Vector.(); newVector = newVector.concat(tmp);
But then you get a type error converting Array to Vector.
I'm stumped, am I missing something stupid or does the vector class really not play well with numeric types? You can try making them decimal numbers just to be sure they get cast as number and not int.
Because of the inability to create Vectors dynamically, I'm forced to create one with a very primitive type, i.e. Object: var list:Vector.<Object> = new Vector.<Object>(); I'm assuming that Vector gains its power from being typed as closely as possible, rather than the above, but I may be wrong and there are in-fact still gains when using the above in place of a normal Array or Object:
I have an air application that I'd like to turn into a multi-player game. I'd like to have 2-40 concurrent connections per "room". We would like to have 1-10 rooms going at once in the beginning. I'd like for users to be able to share voice and video but that's not a requirement.
Users will be racing each other based on data that's updated once every second, so ping doesn't have to be super low. 1000ms would be fine but lower is preferred.[URL]..
Cirrus looks perfect. I've heard some problems about firewall and port settings, but was wondering if anyone had experience with at home users and Cirrus. Another problem is that it's been in labs for ever. You can get RTMFP with Flash Media Server Enterprise but that's like 60k-70k per processor, way out of our price range. I've also looked at [URL] but it doesn't support RTMFP. I know we can host this on AWS and maybe save some money.
There is an open source project (cumulus) that implements RTMFP too but I've read that it's more of a POC then a production ready project. The license is also GPL which doesn't work for our commercial application. I've also looked at[URL].. but again, no RTMFP integration.The reason I like RTMFP is because we can scale without a lot of server cost. I know it's a closed protocol from Adobe and it looks like wowza or red5 won't be implementing it any time soon.
Is there an affordable (not 70k per processor) server tech for multi-player gaming that you can use with AIR/Flash that scales well?
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.
ActionScript Code: 1067: Implicit coercion of a value of type __AS3__.vec:Vector.ie.aro.floorplanviewer.model.buildingVOs:ConfigurationVO>[code]....
which surprises me as ConfigurationVO inherits from NodeVO.Is the compiler really not able to figure out that a Vector of a superclass should be able to hold a reference to a Vector of a subclass?
I need to import a bunch of vector work from Photoshop into Flash. Is there a trick to it. So far, on import, it's converting the layer styles into black.