-
Load XML
I have an open source fla that reads a xml for an array and I ran across this code. Can any of you gurus tell me what this means?
multiNodeObject.prototype.length = function() {
var count = 0;
for (var name in this) {
var addCount = true;
for (var i = 0; i<name.length; i++) {
if (name.charCodeAt(i)<48 || name.charCodeAt(i)>57) {
addCount = false;
}
}
if (addCount) {
count++;
}
}
return count;
};
Specifically the charCodeAt code -- I'm lost, thanks!
-
Hmm, Might have put this in the wrong section, can someone move this to Actionscripting or backend? Thanks.
-
Senior Member
That determines the character in a string:
charCodeAt(0) is the first character in a string.
- The right of the People to create Flash movies shall not be infringed. -
-
Thanks for the reply.
Sorry, I still no understand. I traced the charCodeAt(i) and it gave me 104. No idea how or why that's there. I'm a fairly good scripter/troubleshooter, but can't figure this one out. And there's not a lot of info on the net about it either...maybe a couple of examples from one of you to get [different] results? Just a curious question. Not out to change the world or anything Thanks.
-
Senior Member
Flash help files This method is similar to String.charAt() except that the returned value is a 16-bit integer character code, not a character.
Check this:
myString = "This is a short string."
for (i=0;i<=myString.length;i++) {
trace(myString.charCodeAt(i));
}
- The right of the People to create Flash movies shall not be infringed. -
-
OK, so I'm getting closer breaking the code thanks to your trace sample
This particular portion of the AS -
for (var i = 0; i if (name.charCodeAt(i)<48 || name.charCodeAt(i)>57) {
is disputing numbers 1 - 9 (>48 <57)?
and the way it currently spits it out, it spells "length".
Closer, but still lost....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|