A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: Well there is Prototypes and Array in the Q

  1. #1
    The ActionScript Master Master64's Avatar
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    654

    Well there is Prototypes and Array in the Q

    Hoi

    this has me jumping

    i got this from http://proto.layer51.com/d.aspx?f=749

    but its not working
    code:

    Array.prototype.findAndRemove = function(toRemove) {
    this = this.toString().split(toRemove+",").join("").split (",");
    trace(this)// this trace shows that the toRemove has been removed
    };
    myArray = new Array(1, 2, 3, 3, 5, 6, 7, 8, 3, 0);
    myArray.findAndRemove(3);
    trace(myArray);//but when i trace myArray nothing has changed!!



    its as if the change of the prototype function is not saved!!
    is there some one who knows more about Prototype stuff here

    Thanks
    Master64
    useing:XP,MX

    don't send me PM's because i never check it so if you what to contact me use Email

  2. #2
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    Hi,

    you could try this instead,

    code:

    Array.prototype.findAndRemove = function(toRemove) {
    return this.toString().split(toRemove+",").join("").split (",");
    };
    myArray = new Array(1, 2, 3, 3, 5, 6, 7, 8, 3, 0);
    myArray = myArray.findAndRemove(3);
    trace(myArray);


  3. #3
    The ActionScript Master Master64's Avatar
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    654
    Hoi

    your right but that function should just work as it is

    thanks
    Master64
    useing:XP,MX

    don't send me PM's because i never check it so if you what to contact me use Email

  4. #4
    half as fun, double the price senocular's Avatar
    Join Date
    Feb 2002
    Location
    San Francisco, CA (USA)
    Posts
    4,361
    make sure you're exporting in Flash 6. It wont work in 5.

  5. #5
    The ActionScript Master Master64's Avatar
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    654
    Hoi

    that was one of the fisrt thing i checked becaues i am always messing up there

    Master64
    useing:XP,MX

    don't send me PM's because i never check it so if you what to contact me use Email

  6. #6
    half as fun, double the price senocular's Avatar
    Join Date
    Feb 2002
    Location
    San Francisco, CA (USA)
    Posts
    4,361
    Does that mean you figured out your problem?

  7. #7
    The ActionScript Master Master64's Avatar
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    654
    no





    Master64
    useing:XP,MX

    don't send me PM's because i never check it so if you what to contact me use Email

  8. #8
    half as fun, double the price senocular's Avatar
    Join Date
    Feb 2002
    Location
    San Francisco, CA (USA)
    Posts
    4,361
    return the this =

    then set array var to function call


  9. #9
    The ActionScript Master Master64's Avatar
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    654
    Hoi

    well i have a blank movie wiht no thing in it just this on the first frame
    code:

    Array.prototype.findAndRemove = function(toRemove) {
    this = this.toString().split(toRemove+",").join("").split (",");
    trace(this);
    // this trace shows that the toRemove has been removed
    };
    myArray = new Array(1, 2, 3, 3, 5, 6, 7, 8, 3, 0);
    myArray.findAndRemove(3);
    trace(myArray);
    //but when i trace myArray nothing has changed!!


    and this is what i get in my output window
    1,2,5,6,7,8,0
    1,2,3,3,5,6,7,8,3,0


    thanks
    Master64
    useing:XP,MX

    don't send me PM's because i never check it so if you what to contact me use Email

  10. #10
    The ActionScript Master Master64's Avatar
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    654
    Originally posted by senocular
    return the this =

    then set array var to function call

    sorry but i don't get it
    Master64
    useing:XP,MX

    don't send me PM's because i never check it so if you what to contact me use Email

  11. #11
    half as fun, double the price senocular's Avatar
    Join Date
    Feb 2002
    Location
    San Francisco, CA (USA)
    Posts
    4,361
    what catbert303 put

  12. #12
    The ActionScript Master Master64's Avatar
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    654
    ok

    but the function does work with you?

    well then its my computer

    thanks for you help


    Last edited by Master64; 07-23-2003 at 12:52 PM.
    Master64
    useing:XP,MX

    don't send me PM's because i never check it so if you what to contact me use Email

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