So, the case he brought up was different from what you said.
In your case you're creating differently named movie clips, and
explicitly assigning them to the mc variable.
In the original code, a new movie clip was attached with the same
name, but NOT assigned to the variable. After doing so you would
expect the variable to not work, but it ended up pointing to the new
clip.
-Andy
On Mon, Mar 10, 2008 at 4:27 PM, Glen Pike <[EMAIL PROTECTED]> wrote:
> Sorry if I am speaking out of turn, but isn't this point a bit moot
> (redundant)?
>
> How else would you expect to be able to attach movieclips and manipulate
> them in a loop as you would normally?
>
> e.g.
>
> function doClips() {
> var mc:MovieClip;
>
> for(var i = 0;i < 10;i++) {
> mc = attachMovie("star", "star_mc_" + i, getNextHighestDepth());
> //mc.removeClip();
> mx._x = 100 * i;
> }
>
> //would expect to manipulate the last one.
> mc._y = 100;
> }
>
> doClips();
> //compile error, but would not work anyway.
> mc._y = 200;
> //would work.
> star_mc_9._y = 200;
>
> I bet the reference goes out of scope once you exit the function you are in?
>
> If not, then that maybe a bug.
>
> Glen
>
>
>
> Andy Herrman wrote:
> > So you're saying variables like mc are effectively pointers?
> >
> > Well crap. I thought I didn't have to worry about pointers when I
> > wasn't working in C... :)
> >
> > (I say after just debugging some really weird memory issue in C++ code...)
> >
> > -Andy
> >
> > On Mon, Mar 10, 2008 at 4:08 AM, strk <[EMAIL PROTECTED]> wrote:
> >
> >> On Sun, Mar 09, 2008 at 06:50:58PM +0300, Pavel Empty wrote:
> >>
> >> > //Create a clip from the library and store its reference to "mc"
> variable.
> >> > var mc:MovieClip = _root.attachMovie("Star", "star_mc",
> >> > _root.getNextHighestDepth());
> >>
> >> 'mc' is a "soft reference" to the Star instance.
> >>
> >>
> >> > //Destroy the clip
> >> > mc.removeMovieClip();
> >>
> >> 'mc' becomes a "dangling" reference, which means it'll be looking
> >> for a substitute with same target name when dereferenced.
> >>
> >>
> >> > //Create another star clip once again with the same name "star_mc"
> >> > //Notice that I do not assign the clip reference to "mc" variable.
> >> > _root.attachMovie("Star", "star_mc", _root.getNextHighestDepth());
> >> >
> >> > //And now I move "mc". It references the first clip, which was
> destroyed.
> >> > //I expect nothing to happen, but...
> >> > mc._x = 100;
> >> >
> >> > The second clip moves!
> >> > That is, the second clip was referenced using "mc".
> >>
> >> Dereferencing 'mc' here yelds the new Star insatnce, having
> >> the same target path as the original one.
> >>
> >> --strk;
> >>
> >>
> >> _______________________________________________
> >> Flashcoders mailing list
> >> [email protected]
> >> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >>
> >>
> > _______________________________________________
> > Flashcoders mailing list
> > [email protected]
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
> >
> >
>
> --
>
> Glen Pike
> 01736 759321
> www.glenpike.co.uk <http://www.glenpike.co.uk>
>
>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders