dcsimg
A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Load XML

Hybrid View

  1. #1
    muvipix.com
    Join Date
    May 2001
    Location
    Maine
    Posts
    289

    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!
    Regards,

    Ron

  2. #2
    muvipix.com
    Join Date
    May 2001
    Location
    Maine
    Posts
    289
    Hmm, Might have put this in the wrong section, can someone move this to Actionscripting or backend? Thanks.
    Regards,

    Ron

  3. #3
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    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. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  4. #4
    muvipix.com
    Join Date
    May 2001
    Location
    Maine
    Posts
    289
    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.
    Regards,

    Ron

  5. #5
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    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. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  6. #6
    muvipix.com
    Join Date
    May 2001
    Location
    Maine
    Posts
    289
    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....
    Regards,

    Ron

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center