Try using a variable local to the for loop for the target:
//this also sets the event handling in one shot
for (i=0; i<5; i++) {
clipName = this["clip"+i];
var myTarget= _root["text"+i]
trace(target);
clipName.onRollOver = function() {
Tweener.addTween(this.person,{_alpha:100, delay:0, time:2});
Tweener.addTween(this.whiteborder,{_alpha:100, delay:0, time:2});
Tweener.addTween(myTarget,{_alpha:100, delay:0, time:2});
trace("onrollover"+myTarget);
};
clipName.onRollOut = function() {
Tweener.addTween(this.person,{_alpha:30, delay:0, time:1});
Tweener.addTween(this.whiteborder,{_alpha:0, delay:0, time:1});
Tweener.addTween(myTarget,{_alpha:0, delay:0, time:2});
};
}
My guess is target is declared outside the for loop, so you're having
some problems with closure. I don't know if AS's closure works the
same way as C#'s, but if it does then this could be the problem.
This article is specific to C#, but it does a good job of going over
how closures and anonymous methods work, and might be helpful to
understand this (assuming I'm right in that AS's behavior matches C#'s
for closure)
http://www.theserverside.net/tt/articles/showarticle.tss?id=AnonymousMethods
search for the "Captured local variables and code visibility" section
for an example of the possible differences between what you have and
what I suggested.
-Andy
On Jan 16, 2008 2:13 AM, Dwayne Neckles <[EMAIL PROTECTED]> wrote:
> OK
>
> on rollover the correponding text clip fades in on rollout it fades out..
>
> during debuging.. all of the targets are "text4" and it shouldnt be..
>
> clip0 should control text0 and etc..
> but what happens is that clip0 to clip4 controls text4...
>
> which is wrong, any suggestions?
>
>
> Code below:
>
> //this also sets the event handling in one shot
> for (i=0; i<5; i++) {
> clipName = this["clip"+i];
> target= _root["text"+i]
> trace(target);
>
>
> clipName.onRollOver = function() {
> Tweener.addTween(this.person,{_alpha:100, delay:0, time:2});
> Tweener.addTween(this.whiteborder,{_alpha:100, delay:0, time:2});
> Tweener.addTween(target,{_alpha:100, delay:0, time:2});
> trace("onrollover"+target);
>
>
> };
>
> clipName.onRollOut = function() {
> Tweener.addTween(this.person,{_alpha:30, delay:0, time:1});
> Tweener.addTween(this.whiteborder,{_alpha:0, delay:0, time:1});
> Tweener.addTween(target,{_alpha:0, delay:0, time:2});
>
> };
>
>
> }
>
>
>
> > Date: Tue, 15 Jan 2008 21:32:41 -0800
> > To: flashcoders@chattyfig.figleaf.com
> > From: [EMAIL PROTECTED]
> > Subject: Re: [Flashcoders] buttons lined up next to each other- rollout
> > not work
>
> >
> > No such problem here with either adjacent or overlapping buttons.
> > Please post your code. Here's mine for four buttons named "btn1," "btn2,"
> > etc.:
> >
> > for (i = 1; i < 5; i++) {
> > this["btn" + i].onRollOut = function() {
> > trace(this._name);
> > };
> > }
> >
> > Marc
> >
> > At 09:06 PM 1/15/2008, you wrote:
> >
> > >This is probably a classic issue..
> > >
> > >I have 5 buttons lined up next to each with no space between but
> > >they arent overlapping.
> > >
> > >I have rollover and rollout events.. but the rollout event doesnt
> > >work when i roll over to the next button..
> > >
> > >the onrollout event works only when i rollout on to negative
> > >space..which sucks
> > >is there a workaround
> >
> > ___
> > Flashcoders mailing list
> > Flashcoders@chattyfig.figleaf.com
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> _
> Share life as it happens with the new Windows Live.
> http://www.windowslive.com/share.html?ocid=TXT_TAGHM_Wave2_sharelife_012008___
>
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders