Hi,
I’m trying to create buttons from MovieClips that use a tween to change their opacity and enlarge them. The code for the up state looks like this:
[FONT=“Courier New”]var evtTargetalpha:Tween;
var evtTargetscaleX:Tween;
var evtTargetscaleY:Tween;
function btnEnlarge(evt:MouseEvent):void {
var mcTargetGrow:Object = evt.target;
evt.target.removeEventListener(MouseEvent.ROLL_OVER, btnEnlarge);
evtTargetalpha = new Tween(mcTargetGrow, “alpha”, Regular.easeOut, 0, 1, .2, true);
evtTargetalpha.addEventListener(TweenEvent.MOTION_FINISH, changeBtnSize);
function changeBtnSize(evt:TweenEvent):void {
sndBooks.play();
evtTargetscaleX = new Tween(mcTargetGrow, "scaleX", Regular.easeOut, 0.545, 1, .5, true);
evtTargetscaleY= new Tween(mcTargetGrow, "scaleY", Regular.easeOut, 0.545, 1, .5, true);
}
evt.target.addEventListener(MouseEvent.ROLL_OUT, btnShrink);
}[/FONT]
Occasionally the buttons will stutter or flash as if they are registering the roll_over multiple times. I thought that maybe the problem is that the tween is on the button itself. I created a MovieClip as the hit state and wanted to target a different MovieClip to do the tweening. For instance the evt.target.name would be “button” and the MovieClip that I want to tween would be called button_tw. But I can’t figure out how to do this. I’m mixing up MovieClip instances and strings.
:h:
My questions are: is there a way to access a different MovieClip using evt.target this way? or is this just a bad way to make a button and I should try something else?
Thank you for any advice.