dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: sprite.filters.indexOf?

  1. #1

    sprite.filters.indexOf?

    ok why doesn't this work?
    PHP Code:
    var b:Ball = new Ball();
    var 
    f1:GlowFilter= new GlowFilter(0x0080FF1101021);
    var 
    f2:GlowFilter= new GlowFilter(0xFF95FF1404021);
    b.filters = [f1f2];
    trace(b.filters.indexOf(f1));
    trace(b.filters[0] == f1);
    trace(b.filters[1] == f1); 
    ball is simply a class that extends sprite and draws a circle. I create 2 filters and set them in the filters array, but now how do I know which is which?

    trace output is:
    -1
    false
    false
    Last edited by xMCNUGGETx; 07-17-2009 at 05:59 AM.

  2. #2
    Half Empty happinessSam's Avatar
    Join Date
    May 2003
    Location
    London
    Posts
    442
    At a guess, what you see in the filters array is a clone of the filter you assigned to it, so even if the values are the same the object is different.

    You could always compare them by the color, or if that isn't good enough for you you could always extend the filter and add id as a property to check against (if you do this remember to override clone()).

  3. #3
    Custom User Title Incrue's Avatar
    Join Date
    Feb 2004
    Posts
    974
    You cant acess the filters array directly, you must store a reference of it in another array, do whatever you want with this other and then put back

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