Ah, since the local scope is the object in the array then just using
`toString()` without any arguments would work (just doing
`this.toString()` basically).

Can you provide the code where you populate the array?  It's possible
you're adding something other than the movie clips to the array (or
maybe some type info is being lost).

I'm actually not sure how the `i` variable is handled in this case.
If you're always getting 126 then Flash might be keeping a reference
to the variable and evaluating it when the function runs, instead of
evaluating it when creating the function.  This might be how things
work, I really don't know.  A different way to handle it would be to
do this:

aArray[i].myArrayIndex = i;
aArray[i].onPress = function() { ... }

and then within the function use `this.myArrayIndex` instead of `i`.
This way you're storing the index for the object within the object
itself, so you can query it whenever you want without worrying about
the scope chain.

One other thing, just as a sanity check.  You said you did this:

setInterval(rollOvers,10);  //calls function 100/second to

If that's the actual code then you're going to have problems.  That
will run your rollOvers function every 10 milliseconds.  You probably
only want it run once (no point in changing the onPress functions when
they've already been assigned).  You're going to want to store the
interval's ID and then clear it:

var rollOversInterval:Number = setINterval(rollOvers, 10);

function rollOvers() {
  clearInterval(rollOversInterval);
  /* rest of the function */
}

If for some reason you do need to update the onPress functions you
should really only do it when an event occurs that would require it,
instead of constantly doing so.

  -Andy

On 9/11/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Andy,
>   I see what you are saying, I think.  That the .toString() has to be used
> as a method directly being addressed by the object.  Like I said that what I
> think you are saying.  How ever it seems I still can not get the string
> "myMCinArray1" or  "myMCinArray2" or "myMCinArray3" etc  when I use the
> toString on an array Element.
>
> By the way, the scope in this case is actually  the Array
> lement(MovieClip)  -see coded snippet
>
> setInterval(rollOvers,10);  //calls function 100/second to
>
> function rollOvers(){
>     for (i=0; i<aArray.length; i++) {
>
>         aArray[i].onPress = function() {
>                var myStr:String = aArray[i].toString();   //***** THIS LINE
>                trace(myStr);    // still traces [object object]
>                trace(i);  //gives me 126 .which is the array length. if I
> could get this to give me the value of the Array element clicked I would
> fine too.
>                 };
>     }
> }
>
> Again any follow up on this post would be appreciated.
>
>
> Paul V.
>
>
> ----- Original Message -----
> From: "Andy Herrman" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>; <flashcoders@chattyfig.figleaf.com>
> Sent: Tuesday, September 11, 2007 12:00 PM
> Subject: Re: [Flashcoders] toString(aArray[i]) ?? does this work
>
>
> > I think what you really want is this:
> >
> > var myStr:String = aArray[i].toString();
> >
> > I don't know of any global toString() function.  What's probably
> > happening is that you're doing the equivalent of
> > `this.toString(aArray[i])`.  The scope object's toString function
> > ignores all arguments and gives you the string representation of
> > itself (which will be what you said you're seeing unless it has a
> > custom toString() implementation).
> >
> >   -Andy
> >
> > On 9/10/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > >
> > > Quick question, can I toString an array element.
> > > ie:   var  myStr:String  =  toString(aArray[i]);    // where 'i' is the
> increment.
> > >
> > > I am having an issue with this.  when I trace myStr it traces [object
> object]
> > > instead of what I intended/expected "mcMovieClipName14" as a string.
> > >
> > > Any insite would be appreciated.
> > >
> > > Thanks in advance,
> > >
> > > Paul V.
> > > _______________________________________________
> > > Flashcoders@chattyfig.figleaf.com
> > > To change your subscription options or search the archive:
> > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> > >
> > > Brought to you by Fig Leaf Software
> > > Premier Authorized Adobe Consulting and Training
> > > http://www.figleaf.com
> > > http://training.figleaf.com
> > >
>
>
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to