skyboy / as3-utilities Goto Github PK
View Code? Open in Web Editor NEWA collection of AS3 utilties i've created
License: Other
A collection of AS3 utilties i've created
License: Other
Hey skyboy, huge thanks for the code, but there's definitely a few places where it's falling down.
First is the static emptyNode (line 30, line 36 and a few other places). It's a nice idea, but if you for instance, filter in one LinkedVector, then in that, map another LinkedVector, because they were both set to use the same node, it messed the whole thing up, quite a few runtime errors. I initially just got rid of the private static version of it, but then I realised if you did the same thing for a one instance of a LinkedVector, filter, then inside map it, you'd have the same problem. I got rid of any static entries of emptyNode and now with each function that used it, they create their own 'emptyNode' and all logic now works correctly.
Next is in the constructor of LinkedVector, in 2 lines (line 63 & 64), there's "if (values.length > 1) { if (values == 1)...", I've changed that first check to values.length > 0 and it now seems to work correctly, but I wanted to highlight it to you.
Last place where I'm having problems is splice.
I think rather than going through the problems, a list of where things go wrong might be more helpful to you, so here's the tests I ran,
var lv:LinkedVector = new LinkedVector();
for(var i:int = 19; i < 22; ++i)
lv.push({"a": i, "b": "" + i});
// lv.splice(0, 0);
//all ok, len: 3
// lv.splice(0, 0, {"a": 99, "b": 22}, {"a": 101, "b": 102});
//all ok, len: 5
// lv.splice(0, 2);
//TypeError: Error #1009: Cannot access a property or method of a null object reference.
//at linkedlist.skyboy::LinkedVector/splice()[C:\dev\repos\git\peggleSocialService\frontend\game\src\linkedlist\skyboy\LinkedVector.as:638]
// lv.splice(0, 2, {"a": 99, "b": 22}, {"a": 101, "b": 102});
//all ok, len: 3
// lv.splice(0, 20);
//all ok, len: 0
// lv.splice(0, 20, {"a": 99, "b": 22}, {"a": 101, "b": 102});
//all ok, len: 2
// lv.splice(1, 0);
//all ok, len: 3
// lv.splice(1, 0, {"a": 99, "b": 22}, {"a": 101, "b": 102});
//all ok, len: 5
// lv.splice(1, 1);
//TypeError: Error #1009: Cannot access a property or method of a null object reference.
//at linkedlist.skyboy::LinkedVector/splice()[C:\dev\repos\git\peggleSocialService\frontend\game\src\linkedlist\skyboy\LinkedVector.as:648]
// lv.splice(1, 1, {"a": 99, "b": 22}, {"a": 101, "b": 102});
//ran, but very wrong, length: 6, but only has 1 item, the very first, {a: 19, b: 19}
As you can see, it acts quite irrationally at more than a few points. Currently we're just avoiding splice, before we try and rewrite it, but again I wanted to bring the issues to you.
Thanks, seaders.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.