views:

344

answers:

3

Hello friendly Flashers...

I have a movieClip with a button that I created inside of my display class Thumbnail.as and I have a button function that interacts with it inside of my ui class ThumbnailController.as.

The current problem I'm having is that; in my ui class I can't target the movieClip playGlow which was created inside of my display class.

Code that creates the playGlow button inside my display class (Thumbnail.as)

public function playBtns():void  {
playThumb = new PlayThumb;
playThumb.x = 642;
playThumb.y = 22;
playThumb.alpha = 1;

playGlow = new PlayGlow;
playGlow.x = 628;
playGlow.y = 8;
playGlow.alpha = 1;
}

public function buildRow ():void{
     thumbNailRow.addChild(thumbLoader);
     thumbNailRow.addChild(thumbTitle);
     thumbNailRow.addChild(thumbText);
     thumbNailRow.addChild(playGlow);
     thumbNailRow.addChild(playThumb);

playThumb.addEventListener(MouseEvent.ROLL_OVER, rowRollOver);

addChild(thumbNailRow);
}


Now the code inside of my ui class (ThumbnailController.as)

public function rowRollOver(e:MouseEvent):void
{
     dispatchEvent(new Event(Event.CHANGE, true ));

     TweenPlugin.activate([TintPlugin]);
     TweenLite.to(playGlow, .4, {alpha:.5, tint:0x99cc00});

 }

This is the problem line: TweenLite.to(playGlow, .4, {alpha:.5, tint:0x99cc00});

It will only work when like this: TweenLite.to(this, .4, {alpha:.5, tint:0x99cc00});

But if I use this, the entire thumbNailRow movieClip will tint, I just want to tint the playGlow movieClip which is inside of thumbNailRow, but I don't know how to target that specifically. I get the 1120: Access of undefined property playGlow otherwise.


How can I pass the instance of playGlow into my ui class so I can target that movieClip with my tint tween?

+1  A: 

I'm pretty new to all this AS3 stuff, but have you tried:

TweenLite.to(MovieClip(this).playGlow, .4, {alpha:.5, tint:0x99cc00});

That always works for me when trying to target things.

Sweet this works as well :) too bad I can't check more then one right answer...
Leon
+2  A: 

Try using the event target for the rollover?

TweenLite.to(e.target, .4, {alpha:.5, tint:0x99cc00});

You may have to cast e.target:

TweenLite.to(Sprite(e.target), .4, {alpha:.5, tint:0x99cc00});

at the very least, you should try tracing e.target and let us know what it is.

Iain
Thanks! This works :D I should have thought about trying e.target... w00t!
Leon
A: 

The issue appears to be that e.target is a reference to the playThumb of the thumbNailRow, not the playGlow that you want to affect.

If, in the original code above, thumbnailRow is an instance of the Thumbnail class (and I think it is, can't be sure) then the following should be OK:

public function rowRollOver(e:MouseEvent):void {
    dispatchEvent(new Event(Event.CHANGE, true ));
    TweenPlugin.activate([TintPlugin]);
    var parentThumb: Thumbnail = e.target.parent as Thumbnail; 
    TweenLite.to(parentThumb.playGlow, .4, {alpha:.5, tint:0x99cc00});
 }
HughC
Hi, thanks.. just tried this code, but getting this error:1046: Type was not found or was not a compile-time constant: Thumbnail. And Access of undefined property Thumbnail. thumbNailRow is an instance of the Thumbnail class and it extends ThumbnailController
Leon
you've have to import Thumbnail into your controller class, at the very least (you can't make a type reference to a class in a function body without importing it). I didn't include the import statement because you don't hint at what your package structure is. If you have none, then import Thumbnail;at the top of your controller would suffice.
HughC