Thanks for the response.

The problem in my code is that I have a local variable named the same
as the input parameter 'element:*' of the callback function.  If you
modify the callback function to the following you will see the
behavior that I was describing.

private function isArray(elem:*, index:int, arr:Array):Boolean {
      trace(this);
      var elem : String = "test";
      if (index > 0) {
            return true;
      }
      return false;
}

With your info I was able to find and fix my problem.

As for the this parameter (#2) I can't still figure it out.  If I run
your example in my system, the trace(this) statement in the callback
function outputs the name of the AS file where the callback function sits.

Thanks,
-Sergio


--- In flexcoders@yahoogroups.com, "Francis Cheng" <[EMAIL PROTECTED]> wrote:
>
> Hi Sergio,
>
> Perhaps I'm misunderstanding your question, but I can't reproduce issue
> #1. The following call to the filter method returns a multidimensional
> array:
>
> import flash.display.Sprite;
>
> var arr:Array = [[-1,-2,-3],[3,5,4], "foo"];
>
> function isArray(elem:*, index:int, arr:Array):Boolean {
>       trace(this);
>       if (elem is Array) {
>             return true;
>       }
>       return false;
> }
>
> var mySprite:Sprite = new Sprite();
>
> var newArr:Array = arr.filter(isArray, mySprite);
> trace(newArr[0][0]); // -1
> trace(newArr[0][1]); // -2
> trace(newArr[0][2]); // -3
>
> trace(newArr[1][0]); // 3
> trace(newArr[1][1]); // 5
> trace(newArr[1][2]); // 4
>
> trace(newArr[2]); // undefined
>
>
> As for issue # 2, the thisObject param, it allows you to dictate what
> the "this" reference points to inside the callback function. Notice that
> I trace the value of "this" in the isArray() function. If the thisObject
> param is null, the value of "this" in isArray is the global object, but
> in my example, I create an instance of Sprite and pass that as the
> thisObject, so that the "this" reference points to the instance of
> Sprite named mySprite.
>
> Francis
>
> > -----Original Message-----
> > From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED]
> On
> > Behalf Of sergio_trejo_r
> > Sent: Tuesday, May 16, 2006 1:12 PM
> > To: flexcoders@yahoogroups.com
> > Subject: [flexcoders] Array filter method
> >
> > Hi, two questions regarding the filter method in the Array class.
> >
> > 1) In a two dimensional array the filter method seems to convert the
> > input array into a single dimension array by concatenating the
> > elements of the second array into a CSV string.
> >
> > Is this the expected behavior?
> >
> > 2) Has anyone used the thisObject parameter of the filter method?  It
> > is documented but I haven't found and example and I can't seem to make
> > it work.
> >
> > thanks!
> > -Sergio
> >
> >
> >
> >
> >
> >
> >
> > ------------------------ Yahoo! Groups Sponsor
> >
> > --
> > Flexcoders Mailing List
> > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > Search Archives:
> http://www.mail-archive.com/flexcoders%40yahoogroups.com
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
>







--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




Reply via email to